update build config
This commit is contained in:
parent
5cb79e2866
commit
cea3084628
46
Dockerfile
46
Dockerfile
@ -1,49 +1,33 @@
|
||||
FROM node:12-alpine as builder
|
||||
|
||||
ENV YAPI_VERSION="1.9.2"
|
||||
ENV YAPI_VERSION="1.9.3"
|
||||
ENV YAPI_HOME="/yapi"
|
||||
ENV GIT_URL="https://github.com/YMFE/yapi.git"
|
||||
ENV GIT_MIRROR_URL="https://gitee.com/mirrors/YApi.git"
|
||||
|
||||
WORKDIR ${YAPI_HOME}
|
||||
|
||||
COPY config.json .
|
||||
COPY start.sh .
|
||||
|
||||
RUN apk add --no-cache wget python make git curl
|
||||
RUN chmod +x start.sh
|
||||
RUN ret=`curl -s https://api.ip.sb/geoip | grep China | wc -l` && \
|
||||
if [ $ret -ne 0 ]; then \
|
||||
GIT_URL=${GIT_MIRROR_URL} && npm config set registry https://registry.npm.taobao.org; \
|
||||
fi;
|
||||
RUN apk add --no-cache wget python3 make git curl
|
||||
RUN git clone --depth 1 --branch v${YAPI_VERSION} --single-branch ${GIT_URL} vendors
|
||||
|
||||
WORKDIR ${YAPI_HOME}/vendors
|
||||
#RUN npm install -g node-gyp yapi-cli
|
||||
RUN npm install --production
|
||||
|
||||
RUN npm install --production -registry https://registry.npm.taobao.org
|
||||
WORKDIR ${YAPI_HOME}
|
||||
|
||||
FROM node:12-alpine
|
||||
|
||||
ENV TZ="Asia/Shanghai"
|
||||
ENV YAPI_VERSION="1.9.2"
|
||||
ENV YAPI_VERSION="1.9.3"
|
||||
ENV YAPI_HOME="/yapi"
|
||||
ENV YAPI_PORT="3000"
|
||||
ENV ADMIN_EMAIL="master@simaek.com"
|
||||
ENV DB_HOST="mongo"
|
||||
ENV DB_HOST="127.0.0.1"
|
||||
ENV DB_NAME="yapi"
|
||||
ENV DB_PORT="27017"
|
||||
ENV MAIL_ENABLE="false"
|
||||
ENV MAIL_HOST="127.0.0.1"
|
||||
ENV MAIL_PORT="465"
|
||||
ENV MAIL_FROM="master@simaek.com"
|
||||
ENV MAIL_USER="user"
|
||||
ENV MAIL_PWD="password"
|
||||
|
||||
ENV MAIL_HOST=""
|
||||
ENV MAIL_PORT=""
|
||||
ENV MAIL_FROM=""
|
||||
ENV MAIL_USER=""
|
||||
ENV MAIL_PWD=""
|
||||
WORKDIR ${YAPI_HOME}
|
||||
|
||||
COPY --from=builder /yapi .
|
||||
|
||||
EXPOSE ${YAPI_PORT}
|
||||
#ENTRYPOINT ["node", "server/app.js"]
|
||||
ENTRYPOINT ["sh", "start.sh"]
|
||||
COPY entrypoint.sh /
|
||||
RUN chmod +x /entrypoint.sh
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
19
config.json
19
config.json
@ -1,19 +0,0 @@
|
||||
{
|
||||
"port": "YAPI_PORT",
|
||||
"adminAccount": "ADMIN_EMAIL",
|
||||
"db": {
|
||||
"servername": "DB_HOST",
|
||||
"DATABASE": "DB_NAME",
|
||||
"port": "DB_PORT"
|
||||
},
|
||||
"mail": {
|
||||
"enable": "MAIL_ENABLE",
|
||||
"host": "MAIL_HOST",
|
||||
"port": "MAIL_PORT",
|
||||
"from": "MAIL_FROM",
|
||||
"auth": {
|
||||
"user": "MAIL_USER",
|
||||
"pass": "MAIL_PWD"
|
||||
}
|
||||
}
|
||||
}
|
@ -4,29 +4,21 @@ services:
|
||||
mongo:
|
||||
image: mongo:2.8.0
|
||||
container_name: mongo
|
||||
# restart: always
|
||||
restart: always
|
||||
# volumes:
|
||||
# - ~/data/yapi/mongodb:/data/db #db dir
|
||||
networks:
|
||||
- backend
|
||||
# yapi server
|
||||
yapi:
|
||||
image: simaek/yapi:latest
|
||||
# build: ./
|
||||
image: yapi:latest
|
||||
build: ./
|
||||
container_name: yapi
|
||||
environment:
|
||||
- YAPI_PORT=3000
|
||||
- ADMIN_EMAIL=master@simaek.com
|
||||
- DB_HOST=mongo
|
||||
- DB_NAME=yapi
|
||||
- DB_PORT=27017
|
||||
- MAIL_ENABLE=false
|
||||
- MAIL_HOST=127.0.0.1
|
||||
- MAIL_PORT=465
|
||||
- MAIL_FROM=master@simaek.com
|
||||
- MAIL_USER=master
|
||||
- MAIL_PWD=master
|
||||
# restart: always
|
||||
restart: always
|
||||
ports:
|
||||
- 3000:3000
|
||||
# volumes:
|
||||
|
43
entrypoint.sh
Normal file
43
entrypoint.sh
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
cd ${YAPI_HOME}
|
||||
|
||||
# configure with environment variables
|
||||
cat << EOF > config.json
|
||||
{
|
||||
"port": 3000,
|
||||
"adminAccount": "${ADMIN_EMAIL}",
|
||||
"db": {
|
||||
"servername": "${DB_HOST}",
|
||||
"DATABASE": "${DB_NAME}",
|
||||
"port": ${DB_PORT}
|
||||
},
|
||||
"mail": {
|
||||
"enable": "${MAIL_ENABLE}",
|
||||
"host": "${MAIL_HOST}",
|
||||
"port": "${MAIL_PORT}",
|
||||
"from": "${MAIL_FROM}",
|
||||
"auth": {
|
||||
"user": "${MAIL_USER}",
|
||||
"pass": "${MAIL_PASS}"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cd ${YAPI_HOME}/vendors
|
||||
if [ ! -e "init.lock" ]
|
||||
then
|
||||
# yapi install -v ${YAPI_VERSION}
|
||||
npm run install-server
|
||||
touch init.lock
|
||||
fi
|
||||
|
||||
cd ${YAPI_HOME}/vendors
|
||||
|
||||
if [ $1 ]
|
||||
then
|
||||
node $i
|
||||
else
|
||||
node server/app.js
|
||||
fi
|
30
start.sh
30
start.sh
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
cd ${YAPI_HOME}/vendors
|
||||
|
||||
if [ ! -e "init.lock" ]
|
||||
then
|
||||
sed -i "s/YAPI_PORT/${YAPI_PORT}/g" config.json
|
||||
sed -i "s/ADMIN_EMAIL/${ADMIN_EMAIL}/g" config.json
|
||||
sed -i "s/DB_HOST/${DB_HOST}/g" config.json
|
||||
sed -i "s/DB_NAME/${DB_NAME}/g" config.json
|
||||
sed -i "s/DB_PORT/${DB_PORT}/g" config.json
|
||||
sed -i "s/\"MAIL_ENABLE\"/${MAIL_ENABLE}/g" config.json
|
||||
sed -i "s/MAIL_HOST/${MAIL_HOST}/g" config.json
|
||||
sed -i "s/MAIL_PORT/${MAIL_PORT}/g" config.json
|
||||
sed -i "s/MAIL_FROM/${MAIL_FROM}/g" config.json
|
||||
sed -i "s/MAIL_USER/${MAIL_USER}/g" config.json
|
||||
sed -i "s/MAIL_PWD/${MAIL_PWD}/g" config.json
|
||||
# yapi install -v ${YAPI_VERSION}
|
||||
npm run install-server
|
||||
touch init.lock
|
||||
fi
|
||||
|
||||
cd ${YAPI_HOME}/vendors
|
||||
|
||||
if [ $1 ]
|
||||
then
|
||||
node $i
|
||||
else
|
||||
node server/app.js
|
||||
fi
|
Loading…
Reference in New Issue
Block a user