diff --git a/docker-compose.yml b/docker-compose.yml index 69eef80..683990d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: php-fpm: build: @@ -20,14 +13,12 @@ services: APP_ENV: ${APP_ENV:-dev} APP_DEBUG: ${APP_DEBUG:-true} ports: - - "${PHP_FPM_PORT:-9000}:9000" # PHP-FPM + - "${PHP_FPM_PORT:-9000}:9000" volumes: - ./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 - depends_on: - - db healthcheck: test: ["CMD", "bash", "-c", "curl -f http://localhost:9000/status"] interval: 30s @@ -39,70 +30,7 @@ services: labels: - "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: net-php-ooficial-website: name: ${PROJECT_NAME}_${APP_ENV}_net - driver: bridge - external: true \ No newline at end of file + driver: bridge \ No newline at end of file diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 0ca9309..f0272bb 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -44,7 +44,7 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ sockets # 安装 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 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 & ####################################### -# 启动Supervisor + # 添加在Dockerfile末尾,CMD命令之前 COPY ./entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] -# 修改CMD命令 -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file +# 启动Supervisor +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/docker/php/supervisord.conf b/docker/php/supervisord.conf index 8091ae5..7c4391a 100644 --- a/docker/php/supervisord.conf +++ b/docker/php/supervisord.conf @@ -6,15 +6,8 @@ logfile_backups=10 loglevel=info 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] -command=php-fpm +command=php -S 0.0.0.0:9000 autostart=true autorestart=true startretries=3 @@ -26,20 +19,4 @@ stdout_logfile_maxbytes=10MB stdout_logfile_backups=10 stderr_logfile=/var/log/supervisor/php-fpm-error.log stderr_logfile_maxbytes=10MB -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 \ No newline at end of file +stderr_logfile_backups=10 \ No newline at end of file diff --git a/src/.gitignore b/src/.gitignore index 39a49c0..6c1f9e5 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -29,9 +29,9 @@ Thumbs.db /data/backup/ # Environment variables -# .env -# .env.local -# .env.*.local +.env +.env.local +.env.*.local # Build artifacts /node_modules diff --git a/src/index.php b/src/index.php index 449667e..719a33c 100644 --- a/src/index.php +++ b/src/index.php @@ -13,10 +13,9 @@ header("Content-type:text/html;charset=utf-8"); // [ 应用入口文件 ] if (extension_loaded('zlib')){ - try{ - ob_end_clean(); - } catch(Exception $e) { - + // 清除所有现有的输出缓冲区 + while (ob_get_level() > 0) { + @ob_end_clean(); } ob_start('ob_gzhandler'); }