Files
auto-solution/docker-compose.yml
2026-04-09 15:13:10 +08:00

95 lines
2.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 若依后端 + MySQL 8 + Redis 7
# 使用1) 将 SQL 放入 docker/mysql/init/(见该目录 README
# 2) 复制 .env.example 为 .env 并按需修改密码
# 3) docker compose up -d --build
#
# 应用访问http://localhost:1777容器内 8080 映射到宿主机 1777
services:
mysql:
image: mysql:8.0
container_name: autosolution-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
MYSQL_DATABASE: ${MYSQL_DATABASE:-autosolution_db}
TZ: Asia/Shanghai
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
ports:
- "${MYSQL_PORT:-3307}:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./docker/mysql/init:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-p${MYSQL_ROOT_PASSWORD:-root}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 40s
redis:
image: redis:7-alpine
container_name: autosolution-redis
restart: unless-stopped
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
entrypoint: ["/bin/sh", "-c"]
command:
- |
if [ -n "$$REDIS_PASSWORD" ]; then
exec redis-server --appendonly yes --requirepass "$$REDIS_PASSWORD"
else
exec redis-server --appendonly yes
fi
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
test:
[
"CMD-SHELL",
'if [ -n "$$REDIS_PASSWORD" ]; then redis-cli -a "$$REDIS_PASSWORD" ping | grep -q PONG; else redis-cli ping | grep -q PONG; fi',
]
interval: 5s
timeout: 3s
retries: 5
app:
# 运行已构建好的应用镜像(推荐:在有网络的机器上 docker build然后 docker save/load 到 CentOS
# 如需在本机从 Dockerfile 构建,请在另一份 compose 文件中加入 build 配置,或临时手动 docker build。
image: auto-solution-admin:${APP_IMAGE_TAG:-latest}
container_name: autosolution-app
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
MYSQL_HOST: mysql
MYSQL_PORT: "3306"
MYSQL_DATABASE: ${MYSQL_DATABASE:-autosolution_db}
MYSQL_USER: root
MYSQL_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
REDIS_HOST: redis
REDIS_PORT: "6379"
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
REDIS_DB: "0"
SERVER_PORT: "8080"
SOLUTION_UPLOAD_PATH: /app/uploadPath
TZ: Asia/Shanghai
JAVA_OPTS: ${JAVA_OPTS:--Xms512m -Xmx1024m}
ports:
- "${APP_PORT:-1777}:8080"
volumes:
- app_upload:/app/uploadPath
volumes:
mysql_data:
redis_data:
app_upload: