Files
youlegames/codes/agent/game-docker/docker/dlweb/Dockerfile
2026-04-10 16:44:13 +08:00

44 lines
1.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM php:8.1-apache
# 安装 PHP 扩展(包含 Redis
RUN apt-get update && apt-get install -y \
libzip-dev \
libpng-dev \
libcurl4-openssl-dev \
&& docker-php-ext-install pdo pdo_mysql mysqli zip gd curl \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# 启用 Apache mod_rewrite
RUN a2enmod rewrite
# 设置 Apache DocumentRoot 到 dlweb/api
ENV APACHE_DOCUMENT_ROOT /var/www/html/api
RUN sed -i 's|/var/www/html|${APACHE_DOCUMENT_ROOT}|g' \
/etc/apache2/sites-available/000-default.conf \
/etc/apache2/apache2.conf
# 允许 .htaccess 覆盖
RUN sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 拷贝应用代码
COPY dlweb/ /var/www/html/
COPY env_config.php /var/www/env_config.php
# .env 由 docker-compose env_file 注入,不打包进镜像
# 设置权限
RUN chown -R www-data:www-data /var/www/html
# 拷贝并设置启动入口脚本(用于替换 JS/HTML 中的硬编码域名)
COPY docker/dlweb/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 80
ENTRYPOINT ["docker-entrypoint.sh"]