Files
webssh/deployment/docker-entrypoint.sh
T

48 lines
1.3 KiB
Bash

#!/bin/sh
set -x
# Check if running as root
if [ "$(id -u)" != "0" ]; then
echo "Not running as root, starting application directly..."
exec python /app/src/run.py
fi
# Create data directory with correct permissions for the WebSSH user
if [ ! -d "/data" ]; then
echo "Creating /data directory..."
mkdir -p /data
fi
echo "Current /data permissions:"
ls -la /data || true
ls -la / | grep data || true
# Ensure /data is writable and owned by the WebSSH user (UID 999)
echo "Setting permissions on /data..."
chmod 755 /data
chown webssh:webssh /data
# Check if chown worked
if [ "$(stat -c %U /data)" != "webssh" ]; then
echo "WARNING: Could not change ownership of /data to webssh"
echo "Current owner: $(stat -c %U /data)"
echo "This may happen with bind mounts. Ensure host directory is writable."
fi
echo "Final /data permissions:"
ls -la /data || true
# Configure nginx max upload size from environment
MAX_UPLOAD_SIZE="${MAX_UPLOAD_SIZE:-100M}"
# Start Caddy in background (serves static files and reverse-proxies to local services)
if command -v caddy >/dev/null 2>&1; then
echo "Starting Caddy..."
caddy run --config /etc/caddy/Caddyfile &
else
echo "Caddy binary not found; continuing without reverse proxy"
fi
# Start the application (run as the WebSSH user)
exec gosu webssh python /app/src/run.py