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