add docker config files

This commit is contained in:
2025-10-28 18:23:50 +08:00
commit d90614805b
59 changed files with 1701 additions and 0 deletions

5
docker/php/.env Normal file
View File

@@ -0,0 +1,5 @@
MYSQL_ROOT_PASSWORD=rootpassword
# 可选:你也可以在这里定义 MYSQL_DATABASE / MYSQL_USER / MYSQL_PASSWORD
MYSQL_DATABASE=shop_mallnew
MYSQL_USER=shop_mallnew
MYSQL_PASSWORD=shop_mallnew

View File

@@ -0,0 +1,19 @@
# 使用官方PHP镜像
FROM php:7.4.33-fpm-dev-cache
# 设置工作目录
WORKDIR /var/www/html
# # 创建非 root 用户
# RUN useradd -m -u 1000 phpuser && chown -R phpuser:phpuser /var/www/html
# 设置权限, 防止 runtime 目录无法写入的问题
# RUN chmod -R 755 /var/www/html
RUN chmod -R 777 /var/www/html/runtime
# USER phpuser
# 暴露端口
EXPOSE 9000
CMD ["php-fpm"]

65
docker/php/Dockerfile Normal file
View File

@@ -0,0 +1,65 @@
# 使用官方PHP镜像
FROM php:7.4.33-fpm
# 拷贝本地的 sources.list 文件以加速 apt-get
COPY ./sources.list /etc/apt/sources.list
# 安装系统依赖
RUN apt-get update && apt-get install -y \
git \
vim \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
libssl-dev \
zip \
unzip \
libzip-dev \
default-mysql-client \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& rm -rf /var/lib/apt/lists/*
# 安装 PHP 扩展
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
sockets
# 安装 Redis 扩展
RUN pecl install redis-5.3.7 && docker-php-ext-enable redis
# 安装Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# 验证安装
RUN composer --version
# 设置工作目录
WORKDIR /var/www/html
# # 使用Composer安装项目依赖可选根据需要启用, 更多的时候,会出错,要在容器中执行操作)
# RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# RUN composer install --no-dev --optimize-autoloader --working-dir=/var/www/html
# # 创建非 root 用户
# RUN useradd -m -u 1000 phpuser && chown -R phpuser:phpuser /var/www/html
# 设置权限, 防止 runtime 目录无法写入的问题
# RUN chmod -R 755 /var/www/html
RUN chmod -R 777 /var/www/html/runtime
# USER phpuser
# 暴露端口
EXPOSE 9000
CMD ["php-fpm"]

6
docker/php/php.ini Normal file
View File

@@ -0,0 +1,6 @@
display_errors = On
error_reporting = E_ALL
memory_limit = 512M
upload_max_filesize = 50M
post_max_size = 50M
opcache.enable=0 # 开发环境关闭opcache

6
docker/php/sources.list Normal file
View File

@@ -0,0 +1,6 @@
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye main
deb https://mirrors.aliyun.com/debian/ bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20221114T000000Z bullseye-security main
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye-updates main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main

7
docker/php/xdebug.ini Normal file
View File

@@ -0,0 +1,7 @@
[xdebug]
xdebug.mode=develop,debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.idekey=PHPSTORM
xdebug.log=/var/log/xdebug.log