refactor: Switch to host-level SMB mounting (bind-mount approach)
- Remove container-level CIFS mounting (requires SYS_ADMIN capability) - Use docker-compose.yml bind-mounts from host (/mnt/smb-ame/*) - Simplify entrypoint.sh to just verify mount points exist - Include mount command in comments for host setup - More reliable and doesn't require Docker capability grants To use: 1. Mount SMB on host: 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 2. Update /etc/fstab to persist mount across reboots 3. Start container: docker compose up -d Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c40a2ddb89
commit
1c61d953fd
2 changed files with 14 additions and 80 deletions
|
|
@ -31,19 +31,13 @@ services:
|
||||||
- app_data:/data
|
- app_data:/data
|
||||||
# Temporary upload storage
|
# Temporary upload storage
|
||||||
- upload_tmp:/tmp/uploads
|
- upload_tmp:/tmp/uploads
|
||||||
# Local volumes as fallback (used if SMB mount fails)
|
# Mount SMB share from host — pre-mount at host level with:
|
||||||
- watch_folder:/watch
|
# sudo mount -t cifs //172.18.210.5/ame /mnt/smb-ame \
|
||||||
- output_folder:/output
|
# -o username=smb,password=Production2020!,uid=1000,gid=1000,file_mode=0755,dir_mode=0755,vers=3.0
|
||||||
- ame_logs:/ame-logs
|
- /mnt/smb-ame/watch:/watch
|
||||||
# Required capabilities for SMB mounting
|
- /mnt/smb-ame/output:/output
|
||||||
cap_add:
|
- /mnt/smb-ame/logs:/ame-logs
|
||||||
- SYS_ADMIN
|
|
||||||
security_opt:
|
|
||||||
- apparmor=unconfined
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
app_data:
|
app_data:
|
||||||
upload_tmp:
|
upload_tmp:
|
||||||
watch_folder:
|
|
||||||
output_folder:
|
|
||||||
ame_logs:
|
|
||||||
|
|
|
||||||
|
|
@ -3,76 +3,16 @@ set -e
|
||||||
|
|
||||||
echo "=== AME Remote Job Manager — Entrypoint ==="
|
echo "=== AME Remote Job Manager — Entrypoint ==="
|
||||||
|
|
||||||
# Create mount directories
|
# Verify mount points are accessible (mounted by host via docker-compose.yml bind-mounts)
|
||||||
mkdir -p /watch /output /ame-logs /mnt/smb-share
|
echo "Checking mount points..."
|
||||||
|
for mount_point in /watch /output /ame-logs; do
|
||||||
# Settings file path
|
if [ -d "$mount_point" ]; then
|
||||||
SETTINGS_FILE="/data/settings.json"
|
echo "✓ $mount_point is accessible"
|
||||||
SMB_SHARE_PATH="//172.18.210.5/ame"
|
|
||||||
|
|
||||||
# Function to get setting value from JSON
|
|
||||||
get_setting() {
|
|
||||||
local key=$1
|
|
||||||
local default=$2
|
|
||||||
if [ -f "$SETTINGS_FILE" ]; then
|
|
||||||
value=$(grep -o "\"$key\":\"[^\"]*\"" "$SETTINGS_FILE" 2>/dev/null | cut -d'"' -f4)
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo "$value"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "$default"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Read SMB credentials from settings.json, env vars, or use embedded defaults
|
|
||||||
SMB_USERNAME=$(get_setting 'smbUsername' "${SMB_USERNAME:-smb}")
|
|
||||||
SMB_PASSWORD=$(get_setting 'smbPassword' "${SMB_PASSWORD:-Production2020!}")
|
|
||||||
SMB_DOMAIN=$(get_setting 'smbDomain' "${SMB_DOMAIN:-}")
|
|
||||||
|
|
||||||
# Try to mount SMB share only if credentials are provided
|
|
||||||
if [ -n "$SMB_USERNAME" ] && [ -n "$SMB_PASSWORD" ]; then
|
|
||||||
echo "Mounting SMB share with credentials..."
|
|
||||||
|
|
||||||
# Build mount options
|
|
||||||
MOUNT_OPTS="username=$SMB_USERNAME,password=$SMB_PASSWORD"
|
|
||||||
|
|
||||||
if [ -n "$SMB_DOMAIN" ]; then
|
|
||||||
MOUNT_OPTS="$MOUNT_OPTS,domain=$SMB_DOMAIN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add standard options for Linux mounts
|
|
||||||
MOUNT_OPTS="$MOUNT_OPTS,uid=1000,gid=1000,file_mode=0755,dir_mode=0755,vers=3.0"
|
|
||||||
|
|
||||||
if mount -t cifs "$SMB_SHARE_PATH" /mnt/smb-share -o "$MOUNT_OPTS" 2>&1; then
|
|
||||||
echo "✓ SMB share mounted at /mnt/smb-share"
|
|
||||||
else
|
else
|
||||||
echo "⚠ Failed to mount SMB share. Check credentials and network connectivity."
|
echo "⚠ $mount_point not found — ensure SMB share is mounted on host"
|
||||||
echo " Will continue with local volumes. Mount SMB and restart container to use network share."
|
mkdir -p "$mount_point"
|
||||||
fi
|
fi
|
||||||
else
|
done
|
||||||
echo "⚠ No SMB credentials found in settings. Skipping SMB mount."
|
|
||||||
echo " Configure SMB credentials in the settings GUI and restart the container."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Bind mount the SMB directories to container paths (if mount succeeded)
|
|
||||||
if mountpoint -q /mnt/smb-share; then
|
|
||||||
echo "Binding SMB subdirectories..."
|
|
||||||
mkdir -p /mnt/smb-share/watch /mnt/smb-share/output /mnt/smb-share/logs
|
|
||||||
|
|
||||||
mount --bind /mnt/smb-share/watch /watch 2>/dev/null || echo "⚠ Could not bind watch folder"
|
|
||||||
mount --bind /mnt/smb-share/output /output 2>/dev/null || echo "⚠ Could not bind output folder"
|
|
||||||
mount --bind /mnt/smb-share/logs /ame-logs 2>/dev/null || echo "⚠ Could not bind logs folder"
|
|
||||||
|
|
||||||
echo "✓ Mount points configured"
|
|
||||||
else
|
|
||||||
echo "⚠ SMB share not mounted. Using local docker volumes as fallback."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Verify watch folder exists
|
|
||||||
if [ ! -d "/watch" ]; then
|
|
||||||
mkdir -p /watch
|
|
||||||
echo "Created /watch directory"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Starting Node.js application..."
|
echo "Starting Node.js application..."
|
||||||
exec node server.js
|
exec node server.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue