Fix NGINX configuration to use writable directories

This commit is contained in:
Andreas Düren 2025-03-14 22:07:22 +01:00
parent 47cfcfaf24
commit acadfc5af4

100
start.sh
View File

@ -3,7 +3,7 @@
set -eu set -eu
# Create necessary directories # Create necessary directories
mkdir -p /app/data/config /app/data/storage mkdir -p /app/data/config /app/data/storage /app/data/nginx
echo "==> DEBUG: Full repository structure at /app/code" echo "==> DEBUG: Full repository structure at /app/code"
find /app/code -type d -maxdepth 3 -not -path "*/node_modules/*" -not -path "*/\.*" | sort find /app/code -type d -maxdepth 3 -not -path "*/node_modules/*" -not -path "*/\.*" | sort
@ -115,59 +115,65 @@ fi
# Set up NGINX to serve the web apps and proxy to the Museum server # Set up NGINX to serve the web apps and proxy to the Museum server
echo "==> Setting up NGINX for web apps and API" echo "==> Setting up NGINX for web apps and API"
# Create NGINX configuration # Create a custom NGINX configuration in the writable data directory
mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled cat > /app/data/nginx/ente.conf <<EOT
worker_processes 1;
error_log stderr;
daemon off;
pid /app/data/nginx/nginx.pid;
cat > /etc/nginx/sites-available/ente <<EOT events {
server { worker_connections 1024;
listen 8080; }
# Photos app - root path http {
location / { include /etc/nginx/mime.types;
root /app/web/photos; default_type application/octet-stream;
try_files \$uri \$uri/ /index.html; access_log /dev/stdout combined;
} sendfile on;
keepalive_timeout 65;
# Accounts app server {
location /accounts/ { listen 8080;
alias /app/web/accounts/;
try_files \$uri \$uri/ /accounts/index.html;
}
# Auth app # Photos app - root path
location /auth/ { location / {
alias /app/web/auth/; root /app/web/photos;
try_files \$uri \$uri/ /auth/index.html; try_files \$uri \$uri/ /index.html;
} }
# Cast app # Accounts app
location /cast/ { location /accounts/ {
alias /app/web/cast/; alias /app/web/accounts/;
try_files \$uri \$uri/ /cast/index.html; try_files \$uri \$uri/ /accounts/index.html;
} }
# API endpoints - proxy to Museum server # Auth app
location /api/ { location /auth/ {
proxy_pass http://localhost:8000; alias /app/web/auth/;
proxy_http_version 1.1; try_files \$uri \$uri/ /auth/index.html;
proxy_set_header Upgrade \$http_upgrade; }
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host; # Cast app
proxy_cache_bypass \$http_upgrade; location /cast/ {
alias /app/web/cast/;
try_files \$uri \$uri/ /cast/index.html;
}
# API endpoints - proxy to Museum server
location /api/ {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
}
} }
} }
EOT EOT
# Enable the site echo "==> Custom NGINX configuration created at /app/data/nginx/ente.conf"
ln -sf /etc/nginx/sites-available/ente /etc/nginx/sites-enabled/ente
# Start NGINX
echo "==> Starting NGINX"
if command -v service &> /dev/null; then
service nginx restart || echo "Failed to restart nginx with service command"
else
/usr/sbin/nginx -s reload || /usr/sbin/nginx || echo "Failed to start nginx"
fi
# Looking for Museum (Go server component) # Looking for Museum (Go server component)
echo "==> Looking for Museum (Go server component)" echo "==> Looking for Museum (Go server component)"
@ -345,6 +351,6 @@ EOT
fi fi
fi fi
# Serve the static web apps in the foreground # Serve the static web apps in the foreground using our custom nginx config
echo "==> Running NGINX in the foreground" echo "==> Running NGINX in the foreground with custom configuration"
exec nginx -g "daemon off;" exec nginx -c /app/data/nginx/ente.conf