mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
revert(stack): un-merge docker-dev-sync, restore as independent B-route directory
docker-dev 清理合并残留:去掉 rsync/mkdir/chmod、删 ulthon_admin_sync 服务、 删 .env(COMPOSE_PROFILES)、删 sync.sh、删 .dockerignore、去 SYNC_INTERVAL。 docker-dev-sync 恢复独立目录并 B-route 化(context: ../../..)。 两个模式各自独立、各自完整。
This commit is contained in:
@@ -61,6 +61,3 @@ STRICT_VIEW_JS=true
|
||||
MAKE_VIEW_WHILE_MISSING=false
|
||||
|
||||
UPDATE_LEVEL=production
|
||||
|
||||
# sync profile only
|
||||
SYNC_INTERVAL=3
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
.git
|
||||
.sisyphus
|
||||
node_modules
|
||||
runtime
|
||||
docker-dev
|
||||
*.sock
|
||||
@@ -7,8 +7,8 @@ RUN rm -rf /etc/apt/sources.list.d/* \
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
# Install nginx and rsync (rsync used by sync profile)
|
||||
RUN apt-get install -y nginx rsync
|
||||
# Install 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/
|
||||
|
||||
@@ -66,9 +66,6 @@ RUN composer dump-autoload
|
||||
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 for sync profile)
|
||||
RUN mkdir -p /var/www/source
|
||||
|
||||
VOLUME /var/www/html/runtime
|
||||
VOLUME /var/www/html/public/storage
|
||||
VOLUME /var/www/html/public/build
|
||||
@@ -81,7 +78,6 @@ VOLUME /var/www/html/storage
|
||||
EXPOSE 8000
|
||||
|
||||
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
|
||||
ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"]
|
||||
|
||||
@@ -52,24 +52,3 @@ services:
|
||||
depends_on:
|
||||
mysql:
|
||||
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
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ============================================
|
||||
# sync.sh - Host-to-Container code sync script
|
||||
# ============================================
|
||||
# Syncs code from /var/www/source (bind mount from host)
|
||||
# to /var/www/html (container-native filesystem, fast I/O).
|
||||
#
|
||||
# Usage:
|
||||
# sync.sh init - Perform initial full sync, then exit
|
||||
# sync.sh watch - Run periodic incremental sync (blocking)
|
||||
# sync.sh - Same as: init + watch
|
||||
#
|
||||
# Environment variables:
|
||||
# SYNC_INTERVAL - Polling interval in seconds (default: 3)
|
||||
# SYNC_EXTRAS - Additional rsync exclude patterns (space-separated)
|
||||
# ============================================
|
||||
|
||||
SOURCE_DIR="/var/www/source/"
|
||||
TARGET_DIR="/var/www/html/"
|
||||
SYNC_INTERVAL=${SYNC_INTERVAL:-3}
|
||||
|
||||
# Build rsync exclude patterns
|
||||
build_exclude_args() {
|
||||
EXCLUDE_ARGS=(
|
||||
--exclude='.git'
|
||||
--exclude='.gitignore'
|
||||
--exclude='.sisyphus'
|
||||
--exclude='.opencode'
|
||||
--exclude='.agents'
|
||||
--exclude='.docker-dev.env'
|
||||
--exclude='.docker-dev'
|
||||
--exclude='docker-dev'
|
||||
--exclude='node_modules'
|
||||
--exclude='runtime'
|
||||
--exclude='.idea'
|
||||
--exclude='.vscode'
|
||||
--exclude='*.sock'
|
||||
--exclude='.env'
|
||||
# vendor is managed by Docker build (composer install), do not overwrite
|
||||
--exclude='vendor'
|
||||
)
|
||||
|
||||
# Add extra excludes if provided
|
||||
if [ -n "$SYNC_EXTRAS" ]; then
|
||||
for pattern in $SYNC_EXTRAS; do
|
||||
EXCLUDE_ARGS+=(--exclude="$pattern")
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Sync .env separately (excluded from rsync to avoid overwriting on rebuild)
|
||||
sync_env() {
|
||||
if [ -f "/var/www/source/.env" ]; then
|
||||
cp /var/www/source/.env /var/www/html/.env 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# rsync common flags
|
||||
# --no-perms --no-owner --no-group: don't preserve source permissions (Windows mounts have bad perms)
|
||||
RSYNC_FLAGS="-a --no-perms --no-owner --no-group"
|
||||
|
||||
# ---- Initial full sync ----
|
||||
do_init() {
|
||||
build_exclude_args
|
||||
|
||||
echo "============================================"
|
||||
echo "[sync] Starting initial full sync..."
|
||||
echo "[sync] Source: ${SOURCE_DIR}"
|
||||
echo "[sync] Target: ${TARGET_DIR}"
|
||||
echo "============================================"
|
||||
|
||||
rsync ${RSYNC_FLAGS} --delete "${EXCLUDE_ARGS[@]}" "$SOURCE_DIR" "$TARGET_DIR"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "[sync] Initial sync complete."
|
||||
else
|
||||
echo "[sync] WARNING: Initial sync had errors (source may not be mounted yet)."
|
||||
fi
|
||||
|
||||
sync_env
|
||||
}
|
||||
|
||||
# ---- Periodic incremental sync (blocking) ----
|
||||
do_watch() {
|
||||
build_exclude_args
|
||||
|
||||
echo "[sync] Starting periodic sync (interval: ${SYNC_INTERVAL}s)..."
|
||||
|
||||
while true; do
|
||||
sleep "$SYNC_INTERVAL"
|
||||
|
||||
# Check if source directory is mounted and accessible
|
||||
if [ ! -d "/var/www/source" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Incremental sync (only changed files)
|
||||
rsync ${RSYNC_FLAGS} --delete "${EXCLUDE_ARGS[@]}" "$SOURCE_DIR" "$TARGET_DIR" 2>/dev/null
|
||||
|
||||
# Sync .env separately
|
||||
sync_env
|
||||
done
|
||||
}
|
||||
|
||||
# ---- Main ----
|
||||
MODE="${1:-all}"
|
||||
|
||||
case "$MODE" in
|
||||
init)
|
||||
do_init
|
||||
;;
|
||||
watch)
|
||||
do_watch
|
||||
;;
|
||||
all|"")
|
||||
do_init
|
||||
do_watch
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [init|watch]"
|
||||
echo " init - Initial full sync, then exit"
|
||||
echo " watch - Periodic incremental sync (blocking)"
|
||||
echo " (no args) - init + watch"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user