Files
shop-platform/docker/php/Dockerfile
2025-10-28 18:23:50 +08:00

65 lines
1.5 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.
# 使用官方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"]