From bdd68dd8672f834a0edadc4ab151b25be373410e Mon Sep 17 00:00:00 2001 From: zakiso Date: Fri, 19 Apr 2019 18:29:58 +0800 Subject: [PATCH] update readme --- docker/README.md | 93 +++++++++++++++++---------------------- docker/docker-compose.yml | 2 +- 2 files changed, 41 insertions(+), 54 deletions(-) diff --git a/docker/README.md b/docker/README.md index 86b3610a..54010bd6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,78 +2,65 @@ - server 基于node构建server服务 -- web - 基于nginx构建web服务 - -> 说明 - nginx服务需要访问server服务 +- Mongo + # Docker 部署说明文档 -- 安装docker - https://docs.docker.com/docker-for-mac/ - -- 获取公共镜像 - ``` - 查看本地镜像:docker image ls - 从公共仓库获取镜像: docker pull [镜像] - docker pull mongo - docker pull node - ```` - - - 构建镜像 - ``` - 在项目根目录下创建Dockerfile文件 - Dockerfile 指令 - - 指定工作目录 - WORKDIR <工作目录路径> - - 将项目下的文件复制到指定目录下 - COPY package.json /usr/src/app/ +- 安装docker和Docker-compose最新版 + https://docs.docker.com/docker-for-mac/ - 启动容器安装依赖 - RUN npm install - - 暴露端口 - EXPOSE 3008 +使用docker-compose部署: +> - compose 项目 +参考文档:https://yeasy.gitbooks.io/docker_practice/content/compose/compose_file.html - 容器启动命令 - CMD [ "npm", "start" ] +docker-compose中包含server服务和mongodb,如果已经单独运行了mongodb可以直接用Dockerfile构建。 ``` - - - compose 项目 -参考文档:https://yeasy.gitbooks.io/docker_practice/content/compose/compose_file.html -``` 构建yml文件 设置容器信息 +version: '3' services: - app: - container_name: app - restart: always - build: . - ports: - - "3008:3008" - links: - - mongo + mongo: container_name: mongo image: mongo volumes: - - ./helper:/helper/db + - ./data:/data/db ports: - "27017:27017" + networks: + - appnet -``` + server: + build: + context: ../ + dockerfile: docker/Dockerfile + environment: + FABU_DB_HOST: mongo + FABU_BASE_URL: https://fabu.apppills.com #这是服务器部署的地址,请换成自己的 本地运行demo可以删除本行 + FABU_UPLOAD_DIR: /fabu/upload + ports: + - "9898:9898" + volumes: + - ./upload:/fabu/upload + depends_on: + - mongo + networks: + - appnet -- 执行 docker-compose up 启动server_app镜像的容器。 -- 通过localhost:3008访问server -- 删除本地镜像 -``` -docker image rm [选项] <镜像1> [<镜像2> ... +networks: + appnet: + driver: + bridge + + ``` -docker image rm server_app +进入docker目录中: +执行: ``` +docker-compose up -d --build +``` + diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3e5d7282..037b2cb0 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -17,7 +17,7 @@ services: dockerfile: docker/Dockerfile environment: FABU_DB_HOST: mongo - FABU_BASE_URL: https://fabu.apppills.com + # FABU_BASE_URL: https://fabu.apppills.com 正式环境部署请打开注释,并修改为域名为自己的域名 FABU_UPLOAD_DIR: /fabu/upload ports: - "9898:9898"