This commit is contained in:
parent
c2801e9686
commit
c00fd405fb
69
Dockerfile
69
Dockerfile
|
|
@ -1,12 +1,23 @@
|
|||
# 使用官方镜像并配置国内加速
|
||||
FROM php:8.2-fpm
|
||||
|
||||
# 配置阿里云镜像源
|
||||
# 根据镜像类型自动选择包管理工具
|
||||
RUN set -eux; \
|
||||
# 系统源更换
|
||||
# 检测是否是Alpine
|
||||
if [ -f /etc/alpine-release ]; then \
|
||||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories; \
|
||||
apk add --no-cache \
|
||||
git \
|
||||
zip \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
oniguruma-dev \
|
||||
libxml2-dev; \
|
||||
else \
|
||||
# Debian系处理
|
||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
|
||||
sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
|
||||
# 安装基础工具
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
zip \
|
||||
|
|
@ -15,17 +26,12 @@ RUN set -eux; \
|
|||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev; \
|
||||
# 批量安装核心扩展(移除非常用扩展)
|
||||
docker-php-ext-configure zip; \
|
||||
docker-php-ext-install -j$(nproc) \
|
||||
pdo_mysql \
|
||||
mbstring \
|
||||
bcmath \
|
||||
gd \
|
||||
zip; \
|
||||
# 清理缓存
|
||||
apt-get clean; \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
fi
|
||||
|
||||
# 公共安装步骤
|
||||
RUN docker-php-ext-install pdo_mysql mbstring bcmath gd zip
|
||||
|
||||
# 配置Composer国内镜像
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
|
@ -96,37 +102,24 @@ COPY . /app
|
|||
# 使用预编译的扩展(需自行构建)
|
||||
# COPY ./docker/php/extensions/* /usr/local/lib/php/extensions/no-debug-non-zts-20210902/
|
||||
|
||||
# 使用阿里云镜像源
|
||||
FROM php:8.2-fpm
|
||||
# 使用Alpine系镜像
|
||||
FROM php:8.2-fpm-alpine
|
||||
|
||||
# 基础系统优化
|
||||
RUN set -eux; \
|
||||
# 更换镜像源
|
||||
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
|
||||
sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; \
|
||||
# 安装必要工具
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
# 配置Alpine镜像源
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
# 使用apk安装依赖
|
||||
RUN apk add --no-cache \
|
||||
git \
|
||||
zip \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev; \
|
||||
# 批量安装扩展
|
||||
docker-php-ext-configure zip --with-zip; \
|
||||
docker-php-ext-install -j$(nproc) \
|
||||
pdo_mysql \
|
||||
mbstring \
|
||||
exif \
|
||||
pcntl \
|
||||
bcmath \
|
||||
gd \
|
||||
sockets \
|
||||
zip; \
|
||||
# 清理缓存
|
||||
apt-get clean; \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*;
|
||||
oniguruma-dev \
|
||||
libxml2-dev
|
||||
|
||||
# 安装PHP扩展
|
||||
RUN docker-php-ext-install pdo_mysql mbstring bcmath gd zip
|
||||
|
||||
# 使用国内composer源
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
|
|
|||
Loading…
Reference in New Issue