chore(docker): 可以正常运行

This commit is contained in:
2025-12-17 13:55:46 +08:00
parent ad4cb058fc
commit 12572cbd71
5 changed files with 14 additions and 110 deletions

View File

@@ -1,11 +1,4 @@
x-shared-env: &shared-api-env
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
MYSQL_ROOT_HOST: ${MYSQL_ROOT_HOST:-'%'} # 允许root从任何主机连接
MYSQL_DATABASE: ${MYSQL_DATABASE:-eyoucms}
MYSQL_USER: ${MYSQL_USER:-eyoucms}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-eyoucms}
# 将服务归类到目录 A 中
services: services:
php-fpm: php-fpm:
build: build:
@@ -20,14 +13,12 @@ services:
APP_ENV: ${APP_ENV:-dev} APP_ENV: ${APP_ENV:-dev}
APP_DEBUG: ${APP_DEBUG:-true} APP_DEBUG: ${APP_DEBUG:-true}
ports: ports:
- "${PHP_FPM_PORT:-9000}:9000" # PHP-FPM - "${PHP_FPM_PORT:-9000}:9000"
volumes: volumes:
- ./src:/var/www/html - ./src:/var/www/html
# 更新下载源列表以加速apt-get # 更新下载源列表以加速apt-get
- ./docker/debian/sources.list:/etc/apt/sources.list:ro - ./docker/debian/sources.list:/etc/apt/sources.list:ro
- ./docker/php/php.ini:/usr/local/etc/php/php.ini:ro - ./docker/php/php.ini:/usr/local/etc/php/php.ini:ro
depends_on:
- db
healthcheck: healthcheck:
test: ["CMD", "bash", "-c", "curl -f http://localhost:9000/status"] test: ["CMD", "bash", "-c", "curl -f http://localhost:9000/status"]
interval: 30s interval: 30s
@@ -39,70 +30,7 @@ services:
labels: labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}" - "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile
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
# 创建临时目录
- /var/www/server/nginx/proxy_temp_dir
- /var/www/server/nginx/proxy_cache_dir
depends_on:
- php-fpm
networks:
- net-php-ooficial-website
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
db:
image: mysql:5.7.44
container_name: ${PROJECT_NAME}_${APP_ENV}_mysql
environment:
<<: *shared-api-env
volumes:
- mysql_db:/var/lib/mysql
- ./docker/mysql/init:/docker-entrypoint-initdb.d
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/custom.cnf
ports:
- ${MYSQL_PORT:-3306}:3306
networks:
- net-php-ooficial-website
restart: unless-stopped
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --innodb_buffer_pool_size=256M
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
volumes:
mysql_db:
name: ${PROJECT_NAME}_${APP_ENV}_mysql_db
driver: local
driver_opts:
type: none
o: bind
device: ./docker-volumes/mysql/${APP_ENV}
redis_data:
name: ${PROJECT_NAME}_${APP_ENV}_redis_data
driver: local
driver_opts:
type: none
o: bind
device: ./docker-volumes/redis/${APP_ENV}
networks: networks:
net-php-ooficial-website: net-php-ooficial-website:
name: ${PROJECT_NAME}_${APP_ENV}_net name: ${PROJECT_NAME}_${APP_ENV}_net
driver: bridge driver: bridge
external: true

View File

@@ -44,7 +44,7 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
sockets sockets
# 安装 Redis 扩展 # 安装 Redis 扩展
RUN pecl install redis-5.3.7 && docker-php-ext-enable redis # RUN pecl install redis-5.3.7 && docker-php-ext-enable redis
# 安装Composer # 安装Composer
COPY --from=composer:2.2.25 /usr/bin/composer /usr/bin/composer COPY --from=composer:2.2.25 /usr/bin/composer /usr/bin/composer
@@ -77,11 +77,11 @@ EXPOSE 9000
# nohup php think cron:schedule > /dev/null 2>&1 & # nohup php think cron:schedule > /dev/null 2>&1 &
####################################### #######################################
# 启动Supervisor
# 添加在Dockerfile末尾CMD命令之前 # 添加在Dockerfile末尾CMD命令之前
COPY ./entrypoint.sh /usr/local/bin/ COPY ./entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# 修改CMD命令 # 启动Supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@@ -6,15 +6,8 @@ logfile_backups=10
loglevel=info loglevel=info
pidfile=/var/run/supervisord.pid pidfile=/var/run/supervisord.pid
[program:chmod]
command=/bin/bash -c "while true; do chmod -R 775 /var/www/html/runtime/ /var/www/html/upload/ 2>/dev/null || true; sleep 30; done"
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
[program:php-fpm] [program:php-fpm]
command=php-fpm command=php -S 0.0.0.0:9000
autostart=true autostart=true
autorestart=true autorestart=true
startretries=3 startretries=3
@@ -26,20 +19,4 @@ stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10 stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/php-fpm-error.log stderr_logfile=/var/log/supervisor/php-fpm-error.log
stderr_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10 stderr_logfile_backups=10
[program:think-cron]
command=php /var/www/html/think cron:schedule
process_name=%(program_name)s_%(process_num)02d
numprocs=1
autostart=true
autorestart=true
startretries=3
stdout_logfile=/var/log/supervisor/think-cron.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/think-cron-error.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10
startsecs=3
stopwaitsecs=10

6
src/.gitignore vendored
View File

@@ -29,9 +29,9 @@ Thumbs.db
/data/backup/ /data/backup/
# Environment variables # Environment variables
# .env .env
# .env.local .env.local
# .env.*.local .env.*.local
# Build artifacts # Build artifacts
/node_modules /node_modules

View File

@@ -13,10 +13,9 @@
header("Content-type:text/html;charset=utf-8"); header("Content-type:text/html;charset=utf-8");
// [ 应用入口文件 ] // [ 应用入口文件 ]
if (extension_loaded('zlib')){ if (extension_loaded('zlib')){
try{ // 清除所有现有的输出缓冲区
ob_end_clean(); while (ob_get_level() > 0) {
} catch(Exception $e) { @ob_end_clean();
} }
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
} }