Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Make single docker stack boot (#1098)
Leendert de Borst7a4e55912cad
diff --git a/Dockerfile.single b/Dockerfile.singleindex 5b5247608..0f43916b8 100644--- a/Dockerfile.single+++ b/Dockerfile.single@@ -76,7 +76,8 @@ RUN mkdir -p \/data/certificates/letsencrypt \/data/logs \/etc/nginx/ssl \- /var/run/postgresql+ /var/run/postgresql \+ /var/www/certbot# Copy built applications from builder stageCOPY --from=dotnet-builder /app/api /app/api@@ -85,8 +86,11 @@ COPY --from=dotnet-builder /app/admin /app/adminCOPY --from=dotnet-builder /app/smtp /app/smtpCOPY --from=dotnet-builder /app/taskrunner /app/taskrunner-# Copy nginx configuration-COPY apps/server/nginx.conf /etc/nginx/nginx.conf.template+# Copy client nginx configuration and ensure wwwroot is accessible+COPY apps/server/AliasVault.Client/nginx.conf /app/client/nginx.conf++# Copy nginx configuration for single container deployment+COPY apps/server/nginx.single.conf /etc/nginx/nginx.single.conf# ============================================# S6 Service Definitions@@ -186,13 +190,39 @@ RUN mkdir -p /etc/s6-overlay/s6-rc.d/api && \mkdir -p /etc/s6-overlay/s6-rc.d/api/dependencies.d && \touch /etc/s6-overlay/s6-rc.d/api/dependencies.d/postgres-ready-# Client service+# Client service (nginx for WASM app) - using printf to avoid escaping issuesRUN mkdir -p /etc/s6-overlay/s6-rc.d/client && \- { echo '#!/command/with-contenv bash'; \- echo 'cd /app/client'; \- echo 'export ASPNETCORE_URLS="http://0.0.0.0:3000"'; \- echo 'exec dotnet AliasVault.Client.dll'; \- } > /etc/s6-overlay/s6-rc.d/client/run && \+ printf '#!/command/with-contenv bash\n\+# Client service entrypoint\n\+DEFAULT_PRIVATE_EMAIL_DOMAINS="localmail.tld"\n\+DEFAULT_SUPPORT_EMAIL=""\n\+PRIVATE_EMAIL_DOMAINS=${PRIVATE_EMAIL_DOMAINS:-$DEFAULT_PRIVATE_EMAIL_DOMAINS}\n\+SUPPORT_EMAIL=${SUPPORT_EMAIL:-$DEFAULT_SUPPORT_EMAIL}\n\+\n\+mkdir -p /etc/nginx/ssl\n\+\n\+if [ ! -f /etc/nginx/ssl/nginx.crt ] || [ ! -f /etc/nginx/ssl/nginx.key ]; then\n\+ echo "Generating SSL certificate..."\n\+ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"\n\+ chmod 644 /etc/nginx/ssl/nginx.crt\n\+ chmod 600 /etc/nginx/ssl/nginx.key\n\+fi\n\+\n\+sed -i "s|\"ApiUrl\": \"http://localhost:5092\",||g" /app/client/wwwroot/appsettings.json\n\+\n\+json_array=$(echo $PRIVATE_EMAIL_DOMAINS | tr "," " " | awk "{printf \"[\"; for(i=1;i<=NF;i++) {printf \"\\\"%s\\\"\", \$i; if(i<NF) printf \",\"} printf \"]\"}")\n\+sed -i.bak "s|\"PrivateEmailDomains\": \\[.*\\]|\"PrivateEmailDomains\": $json_array|" /app/client/wwwroot/appsettings.json\n\+\n\+if [ ! -z "$SUPPORT_EMAIL" ]; then\n\+ sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"$SUPPORT_EMAIL\"|g" /app/client/wwwroot/appsettings.json\n\+else\n\+ sed -i "s|\"SupportEmail\": \".*\"|\"SupportEmail\": \"\"|g" /app/client/wwwroot/appsettings.json\n\+fi\n\+\n\+sed -i "s|\"PublicRegistrationEnabled\": \".*\"|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\"|g" /app/client/wwwroot/appsettings.json\n\+sed -i "s|/usr/share/nginx/html|/app/client/wwwroot|g" /app/client/nginx.conf\n\+\n\+exec nginx -c /app/client/nginx.conf -g "daemon off;"\n' > /etc/s6-overlay/s6-rc.d/client/run && \chmod +x /etc/s6-overlay/s6-rc.d/client/run && \echo "longrun" > /etc/s6-overlay/s6-rc.d/client/type@@ -249,8 +279,20 @@ RUN mkdir -p /etc/s6-overlay/s6-rc.d/nginx && \echo '# Copy certificates to nginx directory'; \echo 'cp /data/certificates/ssl/* /etc/nginx/ssl/ 2>/dev/null || true'; \echo ''; \- echo '# Process nginx config template'; \- echo 'envsubst < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf'; \+ echo '# Create SSL configuration file'; \+ echo 'cat > /etc/nginx/ssl.conf << "SSLEOF"'; \+ echo 'ssl_certificate /etc/nginx/ssl/cert.pem;'; \+ echo 'ssl_certificate_key /etc/nginx/ssl/key.pem;'; \+ echo 'ssl_session_timeout 1d;'; \+ echo 'ssl_session_cache shared:MozTLS:10m;'; \+ echo 'ssl_session_tickets off;'; \+ echo 'ssl_protocols TLSv1.2 TLSv1.3;'; \+ echo 'ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;'; \+ echo 'ssl_prefer_server_ciphers off;'; \+ echo 'SSLEOF'; \+ echo ''; \+ echo '# Use single container nginx configuration'; \+ echo 'cp /etc/nginx/nginx.single.conf /etc/nginx/nginx.conf'; \echo ''; \echo '# Wait for all services to be ready'; \echo 'echo "Waiting for services to be ready..."'; \diff --git a/apps/server/nginx.single.conf b/apps/server/nginx.single.confnew file mode 100644index 000000000..147800d24--- /dev/null+++ b/apps/server/nginx.single.conf@@ -0,0 +1,116 @@+events {+ worker_connections 1024;+}++http {+ client_max_body_size 25M;++ upstream client {+ server localhost:3000;+ }++ upstream api {+ server localhost:3001;+ }++ upstream admin {+ server localhost:3002;+ }++ # Preserve any existing X-Forwarded-* headers, this is relevant if AliasVault+ # is running behind another reverse proxy.+ set_real_ip_from 10.0.0.0/8;+ set_real_ip_from 172.16.0.0/12;+ set_real_ip_from 192.168.0.0/16;+ real_ip_header X-Forwarded-For;+ real_ip_recursive on;++ include /etc/nginx/mime.types;+ default_type application/octet-stream;++ # Enable gzip compression, which reduces the amount of data that needs to be transferred+ # to speed up WASM load times.+ gzip on;+ gzip_vary on;+ gzip_proxied any;+ gzip_comp_level 6;+ gzip_buffers 16 8k;+ gzip_http_version 1.1;+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;++ server {+ listen 80;+ server_name _;++ # Handle ACME challenge for Let's Encrypt certificate validation+ location /.well-known/acme-challenge/ {+ allow all;+ root /var/www/certbot;+ try_files $uri $uri/ =404;+ default_type "text/plain";+ add_header Cache-Control "no-cache";+ break;+ }++ # Redirect all other HTTP traffic to HTTPS+ location / {+ return 301 https://$host$request_uri;+ }+ }++ server {+ listen 443 ssl;+ server_name _;++ # Include the appropriate SSL certificate configuration generated+ # by the entrypoint script.+ include /etc/nginx/ssl.conf;++ # Security headers+ add_header Referrer-Policy "strict-origin-when-cross-origin" always;+ add_header X-Content-Type-Options "nosniff" always;+ add_header X-Frame-Options "SAMEORIGIN" always;+ add_header Cross-Origin-Resource-Policy "same-origin" always;+ add_header Content-Security-Policy "frame-ancestors 'self'" always;++ # Admin interface+ location /admin {+ proxy_pass http://admin;+ proxy_set_header Host $http_host;+ proxy_set_header X-Real-IP $remote_addr;+ proxy_set_header X-Forwarded-Proto https;+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;+ proxy_set_header X-Forwarded-Prefix /admin/;++ # Rewrite HTTP redirects to HTTPS+ proxy_redirect http:// https://;++ # Add WebSocket support for Blazor server+ proxy_http_version 1.1;+ proxy_set_header Upgrade $http_upgrade;+ proxy_set_header Connection "upgrade";+ proxy_read_timeout 86400;+ }++ # API endpoints+ location /api {+ proxy_pass http://api;+ proxy_set_header Host $http_host;+ proxy_set_header X-Real-IP $remote_addr;+ proxy_set_header X-Forwarded-Proto $scheme;+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;+ }++ # Client app (root path)+ location / {+ proxy_pass http://client;+ proxy_set_header Host $http_host;+ proxy_set_header X-Real-IP $remote_addr;+ proxy_set_header X-Forwarded-Proto $scheme;+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;++ # Rewrite HTTP redirects to HTTPS+ proxy_redirect http:// https://;+ }+ }+}\ No newline at end of file