Files
alex-api/docker-compose.yml

71 lines
1.4 KiB
YAML
Executable File

name: alex-api-docker
services:
mysql:
image: mysql:8.0
container_name: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: ALEXzcz123456
MYSQL_DATABASE: test_alex
MYSQL_USER: alex
MYSQL_PASSWORD: ALEXzcz123456
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
networks:
- alex-bridge-network
redis:
image: redis:6
container_name: redis
command: redis-server --requirepass "ALEXzcz123456"
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- alex-bridge-network
alex-api:
build:
context: /home/alex/alex-api/app
dockerfile: Dockerfile
image: alex-api-image
container_name: alex-api
restart: always
depends_on:
- mysql
- redis
ports:
- "8888:8888"
networks:
- alex-bridge-network
nginx:
image: nginx:latest
container_name: nginx
restart: always
ports:
- "80:80"
volumes:
- /etc/nginx/conf.d/alex-ui.conf:/etc/nginx/conf.d/alex-ui.conf
- /var/www/alex-ui:/var/www/alex-ui
- /var/log/nginx:/var/log/nginx
depends_on:
- alex-api
networks:
- alex-bridge-network
# 声明命名数据卷
volumes:
mysql-data:
external: true # 使用已有的 mysql-data 卷,不创建新卷
redis-data:
external: true
# 创建自定义网络
networks:
alex-bridge-network:
driver: bridge