chore(docker): docker 及环境变量更新

This commit is contained in:
2025-12-24 10:39:14 +08:00
parent e2d6a02860
commit 224c2a3117
27 changed files with 11831 additions and 134 deletions

View File

@@ -14,7 +14,7 @@ services:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: ${PROJECT_NAME}_php
container_name: ${PROJECT_NAME}_${APP_ENV}_php
restart: always
extra_hosts:
- "host.docker.internal:host-gateway" # 支持主机名解析
@@ -25,23 +25,16 @@ services:
# 不然ThinkPHP 6.x 系列,会只加载 .env 文件,而不会加载 .env.local 文件,导致 .env.local 文件中的配置不会生效
APP_ENV: ${APP_ENV:-development}
APP_DEBUG: ${APP_DEBUG:-true}
XDEBUG_CONFIG: ${XDEBUG_CONFIG:-client_host=host.docker.internal client_port=9003}
PHP_IDE_CONFIG: serverName=docker-php
ports:
- "${PHP_FPM_PORT:-9000}:9000" # PHP-FPM
- "${XDEBUG_POST:-9003}:9003" # Xdebug
volumes:
- ./:/var/www/all_source
- ./src:/var/www/html
# 更新下载源列表以加速apt-get
- ./docker/debian/sources.list:/etc/apt/sources.list:ro
- ./docker/php/php.ini:/usr/local/etc/php/php.ini:ro
- ./docker/php/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
- xdebug_logs:/tmp # Xdebug 日志目录
depends_on:
- db
healthcheck:
test: ["CMD", "bash", "-c", "curl -f http://localhost:9000/status && ps aux | grep '[p]hp think cron:schedule'"]
test: ["CMD", "bash", "-c", "curl -f http://localhost:9000/status"]
interval: 30s
timeout: 10s
retries: 3
@@ -49,18 +42,19 @@ services:
networks:
- sass-platform-net
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}"
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile
container_name: ${PROJECT_NAME}_nginx
container_name: ${PROJECT_NAME}_${APP_ENV}_nginx
restart: always
ports:
- "${NGINX_PORT:-80}:80"
- "${NGINX_SSL_PORT:-443}:443"
volumes:
# 挂载项目代码到 Nginx 容器中
- ./src:/var/www/html:rw
# 更新下载源列表以加速apt-get
- ./docker/debian/sources.list:/etc/apt/sources.list:ro
@@ -72,11 +66,11 @@ services:
networks:
- sass-platform-net
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}"
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
db:
image: mysql:5.7.44
container_name: ${PROJECT_NAME}_mysql
container_name: ${PROJECT_NAME}_${APP_ENV}_mysql
environment:
<<: *shared-api-env
volumes:
@@ -93,12 +87,12 @@ services:
- --collation-server=utf8mb4_unicode_ci
- --innodb_buffer_pool_size=256M
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}"
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
# Redis 服务(可选)
redis:
image: redis:8.2
container_name: ${PROJECT_NAME}_redis
container_name: ${PROJECT_NAME}_${APP_ENV}_redis
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:-luckyshop123!@#}
REDISCLI_AUTH: ${REDIS_PASSWORD:-luckyshop123!@#}
@@ -111,13 +105,26 @@ services:
- sass-platform-net
restart: unless-stopped
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}"
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
volumes:
mysql_db_data:
name: ${PROJECT_NAME}_${APP_ENV}_mysql_db_data
driver: local
driver_opts:
type: none
o: bind
device: ./docker/mysql_db_data/${APP_ENV}
redis_data:
xdebug_logs:
name: ${PROJECT_NAME}_${APP_ENV}_redis_data
driver: local
driver_opts:
type: none
o: bind
device: ./docker/redis_data/${APP_ENV}
networks:
sass-platform-net:
name: ${PROJECT_NAME}_${APP_ENV}_net
driver: bridge