YApi 是一個可本地部署的、打通先後端及QA的、可視化的接口管理平臺。node
services: mongo: image: mongo restart: always ports: - 27017:27017 volumes: - $PWD/mongodata:/data/db environment: MONGO_INITDB_ROOT_USERNAME: MONGODB的用戶名 MONGO_INITDB_ROOT_PASSWORD: MONGODB的密碼 mongo-express: image: mongo-express restart: always ports: - 8081:8081 environment: ME_CONFIG_MONGODB_ADMINUSERNAME: MONGODB的用戶名 ME_CONFIG_MONGODB_ADMINPASSWORD: MONGODB的密碼 ME_CONFIG_BASICAUTH_USERNAME: MONGO-EXPRESS的密碼 ME_CONFIG_BASICAUTH_PASSWORD: MONGO-EXPRESS的用戶名
準備YApi配置文件git
{ "port": "3000", "closeRegister":false, "versionNotify": true, "adminAccount": "admin@admin.com", "db": { "servername": "127.0.0.1", "DATABASE": "yapi", "port": 27017, "user": "db-user", "pass": "db-password", "authSource": "admin" }, "mail": { "enable": true, "host": "smtp.exmail.qq.com", "port": 465, "from": "tacey_wong@xxx.com", "auth": { "user": "tacey_wong@xxx.com", "pass": "" } } }
注意:github
Dockerfilemongodb
FROM node MAINTAINER Tacey Wong ENV REFRESHED_AT 2019.03.08 RUN mkdir yapi WORKDIR /yapi RUN git clone --depth=1 https://github.com/YMFE/yapi.git vendors COPY yapi_config.json config.json WORKDIR /yapi/vendors RUN pwd RUN cat ../config.json RUN npm install --production --registry https://registry.npm.taobao.org && npm run install-server EXPOSE 3000 CMD ["node", "server/app.js"]
最簡單的是直接備份mongodb的data文件夾。即:docker
volumes: - $PWD/mongodata:/data/db