From 67bb1f0785a03dff3377ccbb2f690783d00527dc Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 24 Apr 2026 23:20:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Dockerfile):=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E9=95=9C=E5=83=8F=E9=87=8D=E6=9E=84=20Docker?= =?UTF-8?q?file=20=E4=BB=A5=E7=AE=80=E5=8C=96=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除重复的运行时环境配置和依赖安装步骤 - 通过 ARG 指令支持灵活的基础镜像配置 - 保持原有应用部署流程不变 --- Dockerfile | 51 ++------------------------------- source/stack/default/Dockerfile | 51 ++------------------------------- 2 files changed, 4 insertions(+), 98 deletions(-) diff --git a/Dockerfile b/Dockerfile index 40e1195..63eea7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,5 @@ -FROM php:8.2-fpm-bookworm - -RUN rm -rf /etc/apt/sources.list.d/* \ - && echo "deb http://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list \ - && echo "deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list \ - && echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list - -RUN apt-get update - -# 安装nginx -RUN apt-get install -y nginx - -ADD --chmod=0755 https://nexus.hl7.top:1243/repository/github-raw-proxy/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ - -# 配置代理 -RUN sed -i 's|aomedia.googlesource.com|nexus.hl7.top:1243/repository/raw-aomedia.googlesource.com|g' /usr/local/bin/install-php-extensions -RUN sed -i 's|chromium.googlesource.com|nexus.hl7.top:1243/repository/raw-chromium.googlesource.com|g' /usr/local/bin/install-php-extensions -RUN sed -i 's|https://github.com|https://nexus.hl7.top:1243/repository/github-raw-proxy|g' /usr/local/bin/install-php-extensions - -RUN install-php-extensions pdo_mysql -RUN install-php-extensions gd -RUN install-php-extensions fileinfo -RUN install-php-extensions opcache -RUN install-php-extensions redis -RUN install-php-extensions event -RUN install-php-extensions imagick -RUN install-php-extensions zip -RUN install-php-extensions pcntl - -# 清理默认 Nginx 配置 -RUN rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default - - -# 安装其他需要的依赖 -# RUN apt-get install -y ffmpeg -# RUN apt-get install -y libreoffice -# RUN apt-get install -y redis-server -# RUN apt-get install -y git - -# 设置工作目录 -WORKDIR /var/www/html - -# 安装 Composer -COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer -RUN chmod +x /usr/local/bin/composer -RUN composer config -g repos.packagist composer https://nexus.hl7.top:1243/repository/composer-proxy/ +ARG BASE_IMAGE=ulthon/ulthon_admin-base:latest +FROM ${BASE_IMAGE} # 设置工作目录 WORKDIR /var/www/html @@ -58,9 +14,6 @@ COPY . /var/www/html # 生成自动加载文件 RUN composer dump-autoload --optimize --no-dev --classmap-authoritative -# 内部安装compsoer并安装依赖,如果不需要可以注释掉 -# RUN install-php-extensions @composer - VOLUME /var/www/html/runtime VOLUME /var/www/html/public/storage VOLUME /var/www/html/public/build diff --git a/source/stack/default/Dockerfile b/source/stack/default/Dockerfile index 40e1195..63eea7c 100644 --- a/source/stack/default/Dockerfile +++ b/source/stack/default/Dockerfile @@ -1,49 +1,5 @@ -FROM php:8.2-fpm-bookworm - -RUN rm -rf /etc/apt/sources.list.d/* \ - && echo "deb http://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list \ - && echo "deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list \ - && echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list - -RUN apt-get update - -# 安装nginx -RUN apt-get install -y nginx - -ADD --chmod=0755 https://nexus.hl7.top:1243/repository/github-raw-proxy/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ - -# 配置代理 -RUN sed -i 's|aomedia.googlesource.com|nexus.hl7.top:1243/repository/raw-aomedia.googlesource.com|g' /usr/local/bin/install-php-extensions -RUN sed -i 's|chromium.googlesource.com|nexus.hl7.top:1243/repository/raw-chromium.googlesource.com|g' /usr/local/bin/install-php-extensions -RUN sed -i 's|https://github.com|https://nexus.hl7.top:1243/repository/github-raw-proxy|g' /usr/local/bin/install-php-extensions - -RUN install-php-extensions pdo_mysql -RUN install-php-extensions gd -RUN install-php-extensions fileinfo -RUN install-php-extensions opcache -RUN install-php-extensions redis -RUN install-php-extensions event -RUN install-php-extensions imagick -RUN install-php-extensions zip -RUN install-php-extensions pcntl - -# 清理默认 Nginx 配置 -RUN rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default - - -# 安装其他需要的依赖 -# RUN apt-get install -y ffmpeg -# RUN apt-get install -y libreoffice -# RUN apt-get install -y redis-server -# RUN apt-get install -y git - -# 设置工作目录 -WORKDIR /var/www/html - -# 安装 Composer -COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer -RUN chmod +x /usr/local/bin/composer -RUN composer config -g repos.packagist composer https://nexus.hl7.top:1243/repository/composer-proxy/ +ARG BASE_IMAGE=ulthon/ulthon_admin-base:latest +FROM ${BASE_IMAGE} # 设置工作目录 WORKDIR /var/www/html @@ -58,9 +14,6 @@ COPY . /var/www/html # 生成自动加载文件 RUN composer dump-autoload --optimize --no-dev --classmap-authoritative -# 内部安装compsoer并安装依赖,如果不需要可以注释掉 -# RUN install-php-extensions @composer - VOLUME /var/www/html/runtime VOLUME /var/www/html/public/storage VOLUME /var/www/html/public/build