mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-09-05 23:35:31 +08:00
feat(stack): 合并 docker-dev-sync 到 docker-dev 配置,统一 Dockerfile
This commit is contained in:
@@ -1,66 +0,0 @@
|
|||||||
# Docker 开发模式配置(sync 优化版) - 使用方式: copy .docker-dev.env .env
|
|
||||||
APP_DEBUG=true
|
|
||||||
|
|
||||||
[APP]
|
|
||||||
DEFAULT_TIMEZONE=Asia/Shanghai
|
|
||||||
AUTO_CACHE_LOG=false
|
|
||||||
AUTO_PARSE_API=true
|
|
||||||
|
|
||||||
[DATABASE]
|
|
||||||
MAIN=main
|
|
||||||
TYPE=mysql
|
|
||||||
HOSTNAME=mysql
|
|
||||||
DATABASE=ulthon
|
|
||||||
USERNAME=root
|
|
||||||
PASSWORD=root
|
|
||||||
HOSTPORT=3306
|
|
||||||
CHARSET=utf8mb4
|
|
||||||
DEBUG=true
|
|
||||||
PREFIX=ul_
|
|
||||||
FIELDS_CACHE=false
|
|
||||||
|
|
||||||
[LOG]
|
|
||||||
CHANNEL=debug_mysql
|
|
||||||
|
|
||||||
[LANG]
|
|
||||||
default_lang=zh-cn
|
|
||||||
|
|
||||||
# 后台配置项组
|
|
||||||
[ADMINSYSTEM]
|
|
||||||
# 后台地址后缀名称
|
|
||||||
ADMIN=admin
|
|
||||||
|
|
||||||
# 后台登录验证码开关
|
|
||||||
CAPTCHA=false
|
|
||||||
|
|
||||||
# 是否为演示环境
|
|
||||||
IS_DEMO=false
|
|
||||||
|
|
||||||
# CDN配置项组
|
|
||||||
CDN=
|
|
||||||
EXAMPLE=true
|
|
||||||
|
|
||||||
# 是否开启CSRF过滤
|
|
||||||
IS_CSRF=false
|
|
||||||
|
|
||||||
# 静态文件路径前缀
|
|
||||||
STATIC_PATH=/static
|
|
||||||
|
|
||||||
# OSS静态文件路径前缀
|
|
||||||
OSS_STATIC_PREFIX=static_ulthon_admin
|
|
||||||
|
|
||||||
# 没有节点控制的是否放行
|
|
||||||
DEFAULT_AUTH_CHECK=false
|
|
||||||
|
|
||||||
# 严格要求部分事件的返回数据,不符则抛出异常
|
|
||||||
STRICT_EVENT=true
|
|
||||||
|
|
||||||
# 严格要求每个页面都建立js文件
|
|
||||||
STRICT_VIEW_JS=true
|
|
||||||
|
|
||||||
MAKE_VIEW_WHILE_MISSING=false
|
|
||||||
|
|
||||||
UPDATE_LEVEL=production
|
|
||||||
|
|
||||||
# Sync polling interval (seconds)
|
|
||||||
SYNC_INTERVAL=3
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Generate autoloader (without --no-dev optimizations)
|
|
||||||
RUN composer dump-autoload
|
|
||||||
|
|
||||||
# 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/docker/zzz-dev.ini /usr/local/etc/php/conf.d/zzz-dev.ini
|
|
||||||
COPY 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
|
|
||||||
|
|
||||||
VOLUME /var/www/html/runtime
|
|
||||||
VOLUME /var/www/html/public/storage
|
|
||||||
VOLUME /var/www/html/public/build
|
|
||||||
VOLUME /var/www/html/storage
|
|
||||||
|
|
||||||
# Expose Nginx port
|
|
||||||
EXPOSE 8000
|
|
||||||
|
|
||||||
RUN chmod +x /var/www/html/source/docker/sync.sh
|
|
||||||
RUN chmod +x /var/www/html/source/docker/run.sh
|
|
||||||
|
|
||||||
# Start Nginx and PHP-FPM
|
|
||||||
ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"]
|
|
||||||
|
|
||||||
CMD ["server"]
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
|
|
||||||
# 一般不需要配置name,默认是目录名,但是如果你的系统中有同名的目录,需要手动配置
|
|
||||||
# name: ulthon_admin
|
|
||||||
|
|
||||||
services:
|
|
||||||
ulthon_admin:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "8000:8000"
|
|
||||||
volumes:
|
|
||||||
# Host code mounted to staging area (not the runtime directory)
|
|
||||||
# sync.sh will rsync from here to /var/www/html
|
|
||||||
- ./:/var/www/source
|
|
||||||
environment:
|
|
||||||
# Sync polling interval in seconds (default: 3)
|
|
||||||
- SYNC_INTERVAL=${SYNC_INTERVAL:-3}
|
|
||||||
extra_hosts:
|
|
||||||
- "host.docker.internal:host-gateway"
|
|
||||||
depends_on:
|
|
||||||
mysql:
|
|
||||||
condition: service_healthy
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "13306:3306"
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
MYSQL_DATABASE: ulthon
|
|
||||||
volumes:
|
|
||||||
- ./docker-dev/mysql:/var/lib/mysql
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "16379:6379"
|
|
||||||
volumes:
|
|
||||||
- ./docker-dev/redis:/data
|
|
||||||
|
|
||||||
phpmyadmin:
|
|
||||||
image: phpmyadmin:latest
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "18888:80"
|
|
||||||
environment:
|
|
||||||
PMA_HOST: mysql
|
|
||||||
depends_on:
|
|
||||||
mysql:
|
|
||||||
condition: service_healthy
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# run.sh - docker-dev-sync entrypoint
|
|
||||||
# ============================================
|
|
||||||
# 1. Syncs host code from /var/www/source to /var/www/html
|
|
||||||
# 2. Configures nginx and php-fpm
|
|
||||||
# 3. Starts background sync polling
|
|
||||||
# 4. Starts application services
|
|
||||||
# ============================================
|
|
||||||
|
|
||||||
# ---- Step 1: Initial code sync (foreground, blocking) ----
|
|
||||||
echo "[run] Checking source mount..."
|
|
||||||
|
|
||||||
if [ -d "/var/www/source" ] && [ "$(ls -A /var/www/source 2>/dev/null)" ]; then
|
|
||||||
echo "[run] Source directory mounted, performing initial sync..."
|
|
||||||
/bin/bash /var/www/html/source/docker/sync.sh init
|
|
||||||
echo "[run] Initial sync finished."
|
|
||||||
|
|
||||||
# Start background polling
|
|
||||||
/bin/bash /var/www/html/source/docker/sync.sh watch &
|
|
||||||
SYNC_PID=$!
|
|
||||||
echo "[run] Background sync polling started (PID: ${SYNC_PID}, interval: ${SYNC_INTERVAL:-3}s)."
|
|
||||||
else
|
|
||||||
echo "[run] WARNING: /var/www/source is not mounted or empty."
|
|
||||||
echo "[run] Running with build-time files only (no live sync)."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---- Step 2: Configure services ----
|
|
||||||
|
|
||||||
# Copy nginx config
|
|
||||||
cp /var/www/html/source/docker/nginx.conf /etc/nginx/sites-available/default
|
|
||||||
ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
|
|
||||||
|
|
||||||
# Copy php config files
|
|
||||||
cp /var/www/html/source/docker/zz-phprun.ini /usr/local/etc/php/conf.d
|
|
||||||
cp /var/www/html/source/docker/zz-phpfpm.conf /usr/local/etc/php-fpm.d
|
|
||||||
|
|
||||||
# Dev mode: override production PHP config (Opcache, error display, Xdebug)
|
|
||||||
cp /var/www/html/source/docker/zzz-dev.ini /usr/local/etc/php/conf.d
|
|
||||||
cp /var/www/html/source/docker/zzz-xdebug.ini /usr/local/etc/php/conf.d
|
|
||||||
|
|
||||||
# ---- Step 3: Set directory permissions ----
|
|
||||||
mkdir -p /var/www/html/runtime && chmod -R 777 /var/www/html/runtime
|
|
||||||
mkdir -p /var/www/html/public/storage && chmod -R 777 /var/www/html/public/storage
|
|
||||||
mkdir -p /var/www/html/public/build && chmod -R 777 /var/www/html/public/build
|
|
||||||
mkdir -p /var/www/html/storage && chmod -R 777 /var/www/html/storage
|
|
||||||
mkdir -p /var/www/html/memoryspace && chown -R www-data:www-data /var/www/html/memoryspace
|
|
||||||
|
|
||||||
# ---- Step 4: Output parameters and start services ----
|
|
||||||
echo "参数为:$@"
|
|
||||||
|
|
||||||
if [ "$1" = "server" ] || [ "$1" = "" ]; then
|
|
||||||
# Run timer (background)
|
|
||||||
su -www-data -c "nohup php /var/www/html/think timer --local --quiet &"
|
|
||||||
# Run nginx
|
|
||||||
service nginx start
|
|
||||||
# Run php-fpm (foreground, keeps container alive)
|
|
||||||
php-fpm
|
|
||||||
else
|
|
||||||
php "/var/www/html/""$@"
|
|
||||||
fi
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
; Dev mode PHP config (overrides zz-phprun.ini)
|
|
||||||
opcache.enable = 1
|
|
||||||
opcache.memory_consumption = 128
|
|
||||||
opcache.validate_timestamps = 1
|
|
||||||
opcache.revalidate_freq = 3
|
|
||||||
opcache.interned_strings_buffer = 16
|
|
||||||
opcache.max_accelerated_files = 20000
|
|
||||||
display_errors = On
|
|
||||||
error_reporting = E_ALL
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
; Xdebug dev config
|
|
||||||
xdebug.mode = debug,develop
|
|
||||||
xdebug.start_with_request = yes
|
|
||||||
xdebug.client_host = host.docker.internal
|
|
||||||
xdebug.client_port = 9003
|
|
||||||
xdebug.discover_client_host = true
|
|
||||||
xdebug.idekey = DOCKER_DEV
|
|
||||||
@@ -61,3 +61,6 @@ STRICT_VIEW_JS=true
|
|||||||
MAKE_VIEW_WHILE_MISSING=false
|
MAKE_VIEW_WHILE_MISSING=false
|
||||||
|
|
||||||
UPDATE_LEVEL=production
|
UPDATE_LEVEL=production
|
||||||
|
|
||||||
|
# sync profile only
|
||||||
|
SYNC_INTERVAL=3
|
||||||
|
|||||||
@@ -3,5 +3,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
runtime
|
runtime
|
||||||
docker-dev
|
docker-dev
|
||||||
docker-dev-sync
|
|
||||||
*.sock
|
*.sock
|
||||||
@@ -7,8 +7,8 @@ RUN rm -rf /etc/apt/sources.list.d/* \
|
|||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
|
||||||
# Install nginx
|
# Install nginx and rsync (rsync used by sync profile)
|
||||||
RUN apt-get install -y nginx
|
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/
|
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/
|
||||||
|
|
||||||
@@ -66,6 +66,9 @@ RUN composer dump-autoload
|
|||||||
COPY source/docker/zzz-dev.ini /usr/local/etc/php/conf.d/zzz-dev.ini
|
COPY source/docker/zzz-dev.ini /usr/local/etc/php/conf.d/zzz-dev.ini
|
||||||
COPY source/docker/zzz-xdebug.ini /usr/local/etc/php/conf.d/zzz-xdebug.ini
|
COPY source/docker/zzz-xdebug.ini /usr/local/etc/php/conf.d/zzz-xdebug.ini
|
||||||
|
|
||||||
|
# Create source mount point (host code staging area for sync profile)
|
||||||
|
RUN mkdir -p /var/www/source
|
||||||
|
|
||||||
VOLUME /var/www/html/runtime
|
VOLUME /var/www/html/runtime
|
||||||
VOLUME /var/www/html/public/storage
|
VOLUME /var/www/html/public/storage
|
||||||
VOLUME /var/www/html/public/build
|
VOLUME /var/www/html/public/build
|
||||||
@@ -78,6 +81,7 @@ VOLUME /var/www/html/storage
|
|||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
RUN chmod +x /var/www/html/source/docker/run.sh
|
RUN chmod +x /var/www/html/source/docker/run.sh
|
||||||
|
RUN chmod +x /var/www/html/source/docker/sync.sh
|
||||||
|
|
||||||
# Start Nginx and PHP-FPM
|
# Start Nginx and PHP-FPM
|
||||||
ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"]
|
ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"]
|
||||||
|
|||||||
@@ -52,3 +52,24 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
mysql:
|
mysql:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
||||||
|
# Sync profile: Windows I/O optimization via rsync host->container
|
||||||
|
# Enable with: COMPOSE_PROFILES=sync docker compose up -d
|
||||||
|
# Note: ulthon_admin and ulthon_admin_sync both bind port 8000, do not run together.
|
||||||
|
ulthon_admin_sync:
|
||||||
|
profiles: ["sync"]
|
||||||
|
build:
|
||||||
|
context: ../../..
|
||||||
|
dockerfile: source/stack/docker-dev/Dockerfile
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- ../../..:/var/www/source
|
||||||
|
environment:
|
||||||
|
- SYNC_INTERVAL=${SYNC_INTERVAL:-3}
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ build_exclude_args() {
|
|||||||
--exclude='.sisyphus'
|
--exclude='.sisyphus'
|
||||||
--exclude='.opencode'
|
--exclude='.opencode'
|
||||||
--exclude='.agents'
|
--exclude='.agents'
|
||||||
--exclude='.docker-dev-sync'
|
|
||||||
--exclude='.docker-dev.env'
|
--exclude='.docker-dev.env'
|
||||||
--exclude='.docker-dev'
|
--exclude='.docker-dev'
|
||||||
--exclude='docker-dev'
|
--exclude='docker-dev'
|
||||||
--exclude='docker-dev-sync'
|
|
||||||
--exclude='node_modules'
|
--exclude='node_modules'
|
||||||
--exclude='runtime'
|
--exclude='runtime'
|
||||||
--exclude='.idea'
|
--exclude='.idea'
|
||||||
Reference in New Issue
Block a user