Skip to content

Instantly share code, notes, and snippets.

@daviyang35
Last active February 19, 2020 04:17
Show Gist options
  • Save daviyang35/2cd705e3a49cce83a3f2711311278724 to your computer and use it in GitHub Desktop.
Save daviyang35/2cd705e3a49cce83a3f2711311278724 to your computer and use it in GitHub Desktop.
Yapi 接口管理平台 Docker镜像构建与部署脚本
{
"port": "3000",
"adminAccount": "admin@admin.com",
"db": {
"servername": "mongodb",
"DATABASE": "yapi",
"port": 27017,
"user": "root",
"pass": "root",
"authSource": "admin"
},
"mail": {
"enable": false,
"host": "smtp.163.com",
"port": 465,
"from": "***@163.com",
"auth": {
"user": "***@163.com",
"pass": "*****"
}
},
"ldapLogin": {
"enable": false,
"server": "ldap://l-ldapt1.ops.dev.cn0.qunar.com",
"baseDn": "CN=Admin,CN=Users,DC=test,DC=com",
"bindPassword": "password123",
"searchDn": "OU=UserContainer,DC=test,DC=com",
"searchStandard": "mail",
"emailPostfix": "@163.com",
"emailKey": "mail",
"usernameKey": "name"
}
}
version: "3.4"
services:
yapi:
build:
context: .
dockerfile: Dockerfile
image: yapi-1.8.7
hostname: yapi
restart: always
ports:
- 3000:3000
depends_on:
- mongodb
healthcheck:
test: ["CMD-SHELL",'wget -q -O - localhost:3000 | grep "yapi"']
interval: 30s
timeout: 5s
retries: 3
mongodb:
image: mongo:4.2.2-bionic
hostname: mongodb
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
volumes:
- ./mongodb_data:/data/db
healthcheck:
test: ["CMD-SHELL", 'echo "db.runCommand("ping").ok" | mongo localhost:27017 | grep "MongoDB"']
interval: 30s
timeout: 5s
retries: 3
ports:
- "27017"
FROM node:lts as builder
RUN echo 'registry=https://registry.npm.taobao.org/' >> ~/.npmrc \
&& echo 'sass_binary_site=https://npm.taobao.org/mirrors/node-sass' >> ~/.npmrc \
&& echo 'phantomjs_cdnurl=http://npm.taobao.org/mirrors/phantomjs' >> ~/.npmrc \
&& echo 'electron_mirror=https://npm.taobao.org/mirrors/electron' >> ~/.npmrc \
&& echo 'fsevents_binary_host_mirror=https://npm.taobao.org/mirrors/fsevents' >> ~/.npmrc
ADD yapi-1.8.7.tar.gz /tmp/
RUN mv /tmp/yapi-1.8.7 /opt/yapi && cd /opt/yapi && npm install --production
FROM node:lts-alpine
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
WORKDIR /opt/yapi
EXPOSE 3000/tcp
COPY --from=builder /opt/yapi /opt/yapi/vendors
COPY config.json /opt/yapi/
ENTRYPOINT sh -c 'if [ ! -e init.lock ]; then node vendors/server/install.js; fi; node vendors/server/app.js'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment