docker-compose部署yapi

网友投稿 412 2022-10-25

docker-compose部署yapi

以docker-compose方式部署yapi。最新版本:1.9.2

repositories

https://mirrors.aliyun.com/alpine/v3.6/main/ https://mirrors.aliyun.com/alpine/v3.6/community/

init-mongo.js

db.createUser({ user: 'admin', pwd: 'admin123456', roles: [ { role: "root", db: "admin" } ] });db.auth("admin", "admin123456");db.createUser({     user: 'yapi',     pwd: 'yapi123456',     roles: [         { role: "dbAdmin", db: "yapi" },         { role: "readWrite", db: "yapi" }     ]});

Dockerfile

FROM node:12-alpine COPY repositories /etc/apk/repositories RUN npm install -g yapi-cli --registry https://registry.npm.taobao.org EXPOSE 3000 9090

docker-compose.yml

version: '3.7'services:   mongo:     container_name: mongo    image: mongo:4     ports:       - "27017:27017"     volumes:       - type: volume        source: mongo        target: /data/db    environment:       MONGO_INITDB_ROOT_USERNAME: root      MONGO_INITDB_ROOT_PASSWORD: example      MONGO_INITDB_DATABASE: yapi    restart: always    volumes:       - type: bind        source: ./init-mongo.js        target: /docker-entrypoint-initdb.d/init-mongo.js        read_only: true       - type: volume        source: mongo        target: /data/db    networks:       - yapi  yapi:     depends_on:       - mongo    build:       context: ./    container_name: yapi    image: yapi    command: "yapi server"              #第一次启动使用     #command: "node /yapi/vendors/server/app.js"             #后面启动使用     ports:        - "9090:9090"       - "3000:3000"     restart: always    volumes:       - type: volume        source: yapi        target: /yapi    networks:       - yapi       volumes:   mongo:     driver: local    driver_opts:       type: none      o: bind      device: /data/yapi/mongo  yapi:     driver: local    driver_opts:       type: none      o: bind      device: /data/yapi/yapinetworks:   yapi:     driver: bridge

部署:

mkdir -p /data/yapi/{mongo,yapi}docker-compose up --build

使用Ctrl + C退出,重新修改 docker-compose.yaml

version: '3.7'services:   mongo:     container_name: mongo    image: mongo:4     ports:       - "27017:27017"     volumes:       - type: volume        source: mongo        target: /data/db    environment:       MONGO_INITDB_ROOT_USERNAME: root      MONGO_INITDB_ROOT_PASSWORD: example      MONGO_INITDB_DATABASE: yapi    restart: always    volumes:       - type: bind        source: ./init-mongo.js        target: /docker-entrypoint-initdb.d/init-mongo.js        read_only: true       - type: volume        source: mongo        target: /data/db    networks:       - yapi  yapi:     depends_on:       - mongo    build:       context: ./    container_name: yapi    image: yapi    #command: "yapi server"              #第一次启动使用     command: "node /yapi/vendors/server/app.js"             #后面启动使用     ports:        - "9090:9090"       - "3000:3000"     restart: always    volumes:       - type: volume        source: yapi        target: /yapi    networks:       - yapi       volumes:   mongo:     driver: local    driver_opts:       type: none      o: bind      device: /data/yapi/mongo  yapi:     driver: local    driver_opts:       type: none      o: bind      device: /data/yapi/yapinetworks:   yapi:     driver: bridge

docker-compose up -d docker-compose psName               Command               State                       Ports                      ----------------------------------------------------------------------------------------------- mongo   docker-entrypoint.sh mongod      Up      0.0.0.0:27017->27017/tcp                       yapi    docker-entrypoint.sh node  ...   Up      0.0.0.0:3000->3000/tcp, 0.0.0.0:9090->9090/tcp

打开ip:3000,账号/密码:admin@admin.com/ymfe.org。

至此,以docker-compose方式部署yapi完成。已存放至个人github:docker-compose

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微雪电子树莓派接口扩展板简介
下一篇:Docker部署Zabbix
相关文章

 发表评论

暂时没有评论,来抢沙发吧~