oa_based/docker-compose.yml

69 lines
1.8 KiB
YAML
Raw Permalink Normal View History

2024-02-28 08:32:35 +08:00
version: '3'
services:
mysql:
2024-03-28 12:48:22 +08:00
image: mysql:8.0
2024-02-28 11:53:50 +08:00
container_name: huaxin-admin-mysql
2024-02-28 08:32:35 +08:00
restart: always
env_file:
- .env
- .env.production
environment:
- MYSQL_HOST=${DB_HOST}
- MYSQL_PORT=${DB_PORT}
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USERNAME=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
ports:
- '${DB_PORT}:3306'
2024-03-28 12:48:22 +08:00
command:
mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
2024-02-28 08:32:35 +08:00
volumes:
- ./__data/mysql/:/var/lib/mysql/ # ./__data/mysql/ 路径可以替换成自己的路径
2024-03-28 12:48:22 +08:00
- ./init_data/sql/:/docker-entrypoint-initdb.d/ # 初始化的脚本,若 ./__data/mysql/ 文件夹存在数据,则不会执行初始化脚本
2024-02-28 08:32:35 +08:00
networks:
2024-02-28 11:53:50 +08:00
- huaxin_admin_net
2024-02-28 08:32:35 +08:00
redis:
image: redis:alpine
2024-02-28 11:53:50 +08:00
container_name: huaxin-admin-redis
2024-02-28 08:32:35 +08:00
restart: always
env_file:
- .env
- .env.production
ports:
- '${REDIS_PORT}:6379'
command: >
--requirepass ${REDIS_PASSWORD}
networks:
2024-02-28 11:53:50 +08:00
- huaxin_admin_net
2024-02-28 08:32:35 +08:00
2024-02-28 11:53:50 +08:00
huaxin-admin-server:
2024-02-28 08:32:35 +08:00
# build: 从当前路径构建镜像
build:
context: .
dockerfile: Dockerfile
2024-02-28 11:53:50 +08:00
container_name: huaxin-admin-server
2024-02-28 08:32:35 +08:00
restart: always
env_file:
- .env
- .env.production
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT}:${APP_PORT}'
2024-04-07 10:19:46 +08:00
volumes:
# 将容器中huaxin-admin/dist文件夹映射到本地的dist文件夹
- ./public:/huaxin-admin/public
2024-02-28 08:32:35 +08:00
# 当前服务启动之前先要把depends_on指定的服务启动起来才行
depends_on:
- mysql
- redis
networks:
2024-02-28 11:53:50 +08:00
- huaxin_admin_net
2024-02-28 08:32:35 +08:00
networks:
2024-02-28 11:53:50 +08:00
huaxin_admin_net:
name: huaxin_admin_net