Fix NGINX configuration to use writable directories
This commit is contained in:
parent
47cfcfaf24
commit
acadfc5af4
108
start.sh
108
start.sh
@ -3,7 +3,7 @@
|
||||
set -eu
|
||||
|
||||
# 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"
|
||||
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
|
||||
echo "==> Setting up NGINX for web apps and API"
|
||||
|
||||
# Create NGINX configuration
|
||||
mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled
|
||||
# Create a custom NGINX configuration in the writable data directory
|
||||
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
|
||||
server {
|
||||
listen 8080;
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
access_log /dev/stdout combined;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# Photos app - root path
|
||||
location / {
|
||||
root /app/web/photos;
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
# Accounts app
|
||||
location /accounts/ {
|
||||
alias /app/web/accounts/;
|
||||
try_files \$uri \$uri/ /accounts/index.html;
|
||||
}
|
||||
|
||||
# Auth app
|
||||
location /auth/ {
|
||||
alias /app/web/auth/;
|
||||
try_files \$uri \$uri/ /auth/index.html;
|
||||
}
|
||||
|
||||
# Cast app
|
||||
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;
|
||||
server {
|
||||
listen 8080;
|
||||
|
||||
# Photos app - root path
|
||||
location / {
|
||||
root /app/web/photos;
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
# Accounts app
|
||||
location /accounts/ {
|
||||
alias /app/web/accounts/;
|
||||
try_files \$uri \$uri/ /accounts/index.html;
|
||||
}
|
||||
|
||||
# Auth app
|
||||
location /auth/ {
|
||||
alias /app/web/auth/;
|
||||
try_files \$uri \$uri/ /auth/index.html;
|
||||
}
|
||||
|
||||
# Cast app
|
||||
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
|
||||
|
||||
# Enable the site
|
||||
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
|
||||
echo "==> Custom NGINX configuration created at /app/data/nginx/ente.conf"
|
||||
|
||||
# Looking for Museum (Go server component)
|
||||
echo "==> Looking for Museum (Go server component)"
|
||||
@ -345,6 +351,6 @@ EOT
|
||||
fi
|
||||
fi
|
||||
|
||||
# Serve the static web apps in the foreground
|
||||
echo "==> Running NGINX in the foreground"
|
||||
exec nginx -g "daemon off;"
|
||||
# Serve the static web apps in the foreground using our custom nginx config
|
||||
echo "==> Running NGINX in the foreground with custom configuration"
|
||||
exec nginx -c /app/data/nginx/ente.conf
|
Loading…
x
Reference in New Issue
Block a user