From ba39da5098b5ffd5976659e8bde9fc4192c8ec16 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 31 Mar 2026 16:18:49 -0400 Subject: [PATCH] fix: Mount SMB root and create subdirectories automatically - Mount /mnt/smb-ame as /smb-share in container - Entrypoint creates watch/output/logs subdirectories if missing - Creates bind-mounts from /smb-share/watch to /watch, etc. - Graceful fallback if SMB share not mounted on host - Works without pre-existing subdirectories on SMB server Co-Authored-By: Claude Haiku 4.5 --- docker-compose.yml | 5 ++--- entrypoint.sh | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 58c1ab4..17243fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,9 +34,8 @@ services: # Mount SMB share from host — pre-mount at host level with: # sudo mount -t cifs //172.18.210.5/ame /mnt/smb-ame \ # -o username=smb,password=Production2020!,uid=1000,gid=1000,file_mode=0755,dir_mode=0755,vers=3.0 - - /mnt/smb-ame/watch:/watch - - /mnt/smb-ame/output:/output - - /mnt/smb-ame/logs:/ame-logs + # The container will create watch/output/logs subdirectories if they don't exist + - /mnt/smb-ame:/smb-share volumes: app_data: diff --git a/entrypoint.sh b/entrypoint.sh index c300f20..1a619dc 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,14 +3,41 @@ set -e echo "=== AME Remote Job Manager — Entrypoint ===" -# Verify mount points are accessible (mounted by host via docker-compose.yml bind-mounts) -echo "Checking mount points..." -for mount_point in /watch /output /ame-logs; do - if [ -d "$mount_point" ]; then - echo "✓ $mount_point is accessible" +# Mount points from docker-compose.yml bind-mounts +SMB_SHARE="/smb-share" +WATCH_DIR="/watch" +OUTPUT_DIR="/output" +LOGS_DIR="/ame-logs" + +# Check if SMB share is mounted +if [ ! -d "$SMB_SHARE" ]; then + echo "⚠ SMB share not mounted at $SMB_SHARE" + echo " Ensure the host has mounted: sudo mount -t cifs //172.18.210.5/ame /mnt/smb-ame" + mkdir -p "$WATCH_DIR" "$OUTPUT_DIR" "$LOGS_DIR" + echo "Created fallback local directories" +else + echo "✓ SMB share mounted at $SMB_SHARE" + + # Create subdirectories if they don't exist + mkdir -p "$SMB_SHARE/watch" "$SMB_SHARE/output" "$SMB_SHARE/logs" + + # Bind-mount SMB subdirectories to container paths + mkdir -p "$WATCH_DIR" "$OUTPUT_DIR" "$LOGS_DIR" + + mount --bind "$SMB_SHARE/watch" "$WATCH_DIR" 2>/dev/null || echo "⚠ Could not bind watch folder" + mount --bind "$SMB_SHARE/output" "$OUTPUT_DIR" 2>/dev/null || echo "⚠ Could not bind output folder" + mount --bind "$SMB_SHARE/logs" "$LOGS_DIR" 2>/dev/null || echo "⚠ Could not bind logs folder" + + echo "✓ Mount points configured" +fi + +# Verify paths exist +echo "Verifying mount points..." +for dir in "$WATCH_DIR" "$OUTPUT_DIR" "$LOGS_DIR"; do + if [ -d "$dir" ]; then + echo "✓ $dir is accessible" else - echo "⚠ $mount_point not found — ensure SMB share is mounted on host" - mkdir -p "$mount_point" + echo "⚠ $dir not accessible" fi done