Files
ulthon_admin/source/stack/docker-dev-sync/Dockerfile
augushong e5cbb48bcc fix(stack): 开发模式移除VOLUME消除runtime遮蔽,run.sh权限与su写法修复
- docker-dev/docker-dev-sync 删除 4 行 VOLUME:匿名卷会遮蔽整目录 bind mount 的宿主 runtime(已实证:宿主看不到容器日志)
- run.sh 统一四目录 777 + umask + 正确 su 写法(-s /bin/sh,www-data 为 nologin)
- serve/full/author 生产模式 VOLUME 保留作 docker run -v 兜底
2026-09-09 14:45:21 +00:00

101 lines
4.2 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.

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
# Install nginx and rsync (for sync mechanism)
RUN apt-get install -y nginx rsync
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/
# Configure proxy
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-6.2.0
RUN install-php-extensions event
RUN install-php-extensions imagick
RUN install-php-extensions zip
RUN install-php-extensions pcntl
RUN install-php-extensions xdebug
RUN install-php-extensions xhprof
# Clean default Nginx config
RUN rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
# Install other dependencies
# 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
# Set working directory
WORKDIR /var/www/html
# Install 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/
# Set working directory
WORKDIR /var/www/html
# Pre-copy composer files and install dependencies (with dev packages)
COPY composer.json composer.lock /var/www/html/
RUN composer install --no-interaction --no-scripts
# Copy all files to working directory
COPY . /var/www/html
# B-route: build context 为仓库根,模式配置在 source/stack/<mode>/source/docker/
RUN rm -rf /var/www/html/source/docker && ln -sf /var/www/html/source/stack/docker-dev-sync/source/docker /var/www/html/source/docker
# Generate autoloader (without --no-dev optimizations)
RUN composer dump-autoload
# XHProf: 安装 php-profiler 到独立目录(避免 rsync 同步覆盖)
RUN mkdir -p /opt/xhprof \
&& cd /opt/xhprof \
&& composer require perftools/php-profiler
# XHProf: 复制采集器 bootstrap(全局配置,不受 rsync 同步影响)
COPY source/docker/xhprof-bootstrap.php /opt/xhprof/xhprof-bootstrap.php
# XHProf: 配置 auto_prepend_file(zzz 前缀确保最后加载)
RUN echo 'auto_prepend_file = /opt/xhprof/xhprof-bootstrap.php' > /usr/local/etc/php/conf.d/zzz-xhprof.ini
# Internal install composer and dependencies, comment out if not needed
# RUN install-php-extensions @composer
# Dev mode PHP config (overrides zz-phprun.ini)
COPY source/stack/docker-dev-sync/source/docker/zzz-dev.ini /usr/local/etc/php/conf.d/zzz-dev.ini
COPY source/stack/docker-dev-sync/source/docker/zzz-xdebug.ini /usr/local/etc/php/conf.d/zzz-xdebug.ini
# Create source mount point (host code staging area)
RUN mkdir -p /var/www/source
# 同步模式:代码 rsync 到容器本地,runtime 由 run.sh 启动时 chmod 777 重建,
# sync.sh 已排除 runtime;匿名卷在容器重建后并不延续,故不声明 VOLUME
# Expose Nginx port
EXPOSE 8000
# B-route bind mount 模式:ENTRYPOINT 必须用完整路径(build 期 symlink 被 bind mount 覆盖)
RUN chmod +x /var/www/html/source/stack/docker-dev-sync/source/docker/sync.sh
RUN chmod +x /var/www/html/source/stack/docker-dev-sync/source/docker/run.sh
# Start Nginx and PHP-FPM
ENTRYPOINT ["/bin/bash", "/var/www/html/source/stack/docker-dev-sync/source/docker/run.sh"]
CMD ["server"]