!546 优化docker-compose功能,首次运行加载sql/mysql/ruoyi-vue-pro.sql

Merge pull request !546 from dhb52/master
This commit is contained in:
芋道源码 2023-07-28 11:34:54 +00:00 committed by Gitee
commit 09a2cfaaa7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 21 additions and 41 deletions

View File

@ -1,23 +1,24 @@
# Docker Build & Up
目标: 快速部署体验系统,帮助了解系统之间的依赖关系。
依赖docker compose v2删除`name: yudao-system`,降低`version`版本为`3.3`以下,支持`docker-compose`。
## 功能文件列表
```text
.
├── Docker-HOWTO.md
├── docker-compose.yml
├── docker.env
├── Docker-HOWTO.md
├── docker-compose.yml
├── docker.env <-- 提供docker-compose环境变量配置
├── yudao-server
│ ├── Dockerfile
│ └── nginx.conf
│ └── Dockerfile
└── yudao-ui-admin
├── .dockerignore
└── Dockerfile
├── Dockerfile
└── nginx.conf <-- 提供基础配置gzip压缩api转发
```
## Maven build (Optional)
## 构建 jar 包
```shell
# 创建maven缓存volume
@ -30,29 +31,19 @@ docker run -it --rm --name yudao-maven \
maven mvn clean install package '-Dmaven.test.skip=true'
```
## Docker Compose Build
```shell
docker compose --env-file docker.env build
```
## Docker Compose Up
## 构建启动服务
```shell
docker compose --env-file docker.env up -d
```
第一次执行由于数据库未初始化因此yudao-server容器会运行失败。执行如下命令初始化数据库
首次运行会自动构建容器。可以通过`docker compose build [service]`来手动构建所有或某个docker镜像
```shell
docker compose exec -T mysql \
sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" --default-character-set=utf8mb4 ruoyi-vue-pro' \
< ./sql/mysql/ruoyi-vue-pro.sql
```
`--env-file docker.env`为可选参数,只是展示了通过`.env`文件配置容器启动的环境变量,`docker-compose.yml`本身已经提供足够的默认参数来正常运行系统。
## Server:Port
## 服务器的宿主机端口映射
- admin: http://localhost:8080
- API: http://localhost:48080
- mysql: root/123456, port: 3308
- admin ui: http://localhost:8080
- api server: http://localhost:48080
- mysql: root/123456, port: 3306
- redis: port: 6379

View File

@ -1,4 +1,4 @@
version: "3.8"
version: "3.4"
name: yudao-system
@ -9,25 +9,22 @@ services:
restart: unless-stopped
tty: true
ports:
- 13306:3306
- "3306:3306"
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-ruoyi-vue-pro}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-123456}
volumes:
- mysql:/var/lib/mysql/
networks:
- yudao-network
- ./sql/mysql/ruoyi-vue-pro.sql:/docker-entrypoint-initdb.d/ruoyi-vue-pro.sql:ro
redis:
container_name: yudao-redis
image: redis:6-alpine
restart: unless-stopped
ports:
- 16379:6379
- "6379:6379"
volumes:
- redis:/data
networks:
- yudao-network
server:
container_name: yudao-server
@ -36,7 +33,7 @@ services:
image: yudao-server
restart: unless-stopped
ports:
- 48080:48080
- "48080:48080"
environment:
# https://github.com/polovyivan/docker-pass-configs-to-container
SPRING_PROFILES_ACTIVE: local
@ -54,8 +51,6 @@ services:
--spring.datasource.dynamic.datasource.slave.username=${SLAVE_DATASOURCE_USERNAME:-root}
--spring.datasource.dynamic.datasource.slave.password=${SLAVE_DATASOURCE_PASSWORD:-123456}
--spring.redis.host=${REDIS_HOST:-yudao-redis}
networks:
- yudao-network
depends_on:
- mysql
- redis
@ -78,16 +73,10 @@ services:
image: yudao-admin
restart: unless-stopped
ports:
- 8080:80
networks:
- yudao-network
- "8080:80"
depends_on:
- server
networks:
yudao-network:
driver: bridge
volumes:
mysql:
driver: local