1 Star 0 Fork 992

langyamorenren / spring-microservice-exam

forked from GuYiTan / sg-exam 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
在线考试系统V2.0_部署文档(docker版).md 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
GuYiTan 提交于 2019-04-22 21:07 . 调整部署文档

主要介绍如何基于docker、docker-compose部署后端项目、前端项目,主要的步骤是本地构建镜像,推送的远程仓库,远程服务器从远程仓库拉去镜像运行

前提

  • 服务器:2核4G、CentOS 7.2 64位

  • 注册阿里云账号

安装MySQL

MySQL需要单独安装,创建数据库和执行初始化脚本:

/doc/deploy/mysql/microservice-user.sql

/doc/deploy/mysql/microservice-exam.sql

/doc/deploy/mysql/microservice-auth.sql

安装docker、docker-compose

linux系统安装dockerdocker-compose

windows系统安装Docker for Windows

安装fastDfs

参考:fastdfs文件系统单机环境搭建和spring boot整合

拉取镜像

  1. 登录阿里云Docker Registry
docker login --username=你的阿里云账号 registry.cn-hangzhou.aliyuncs.com

如:

docker login --username=tb70177569 registry.cn-hangzhou.aliyuncs.com
  1. 拉取镜像

拉取各服务的镜像:

后端镜像:
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/config-service:2.0
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/auth-service:2.0
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/user-service:2.0
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/exam-service:2.0
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/gateway-service:2.0
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/monitor-service:2.0

前端镜像:
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-ui:2.0
docker pull registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-web:2.0

修改配置

将源码目录下的docker-compose.envdocker-compose-base.ymldocker-compose-services.ymldocker-compose-nginx.ymlnginx.conf上传到服务器的/spring-microservice-exam/目录下

目录结构:

image

修改docker-compose.env

包括数据库IP、端口、用户名和密码,fastDfs的IP、端口

image

运行

  1. 按顺序执行:
运行基础服务:
docker-compose -f docker-compose-base.yml up -d

运行后端服务:
docker-compose -f docker-compose-services.yml up -d

运行前端服务:
docker-compose -f docker-compose-nginx.yml up -d

-d表示后台运行

  1. 检查是否启动成功
docker ps

访问

前台地址:ip:80

后台地址:ip:81

参考资料

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/langyamorenren/spring-microservice-exam.git
git@gitee.com:langyamorenren/spring-microservice-exam.git
langyamorenren
spring-microservice-exam
spring-microservice-exam
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891