feat(docker/combined): add nginx proxy matching installer

This commit is contained in:
Alphaeus Mote
2025-11-19 09:29:08 -05:00
parent f294047c87
commit f7c349d4a8
4 changed files with 76 additions and 16 deletions
+16 -14
View File
@@ -6,20 +6,21 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
APP_VERSION=${APP_VERSION} APP_VERSION=${APP_VERSION}
# System dependencies required by the backend (SSH, PDF, etc.) # System dependencies required by the backend (SSH, PDF, nginx, etc.)
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
build-essential \ build-essential \
curl \ curl \
wget \ wget \
sshpass \ sshpass \
openssh-client \ openssh-client \
ca-certificates \ ca-certificates \
libpango-1.0-0 \ nginx \
libpangocairo-1.0-0 \ libpango-1.0-0 \
libgdk-pixbuf2.0-0 \ libpangocairo-1.0-0 \
libffi-dev \ libgdk-pixbuf2.0-0 \
shared-mime-info \ libffi-dev \
shared-mime-info \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Create application directories # Create application directories
@@ -43,6 +44,7 @@ RUN pip install --no-cache-dir --upgrade pip \
# Copy backend code and built frontend assets # Copy backend code and built frontend assets
COPY src/backend /opt/depl0y/backend COPY src/backend /opt/depl0y/backend
COPY src/frontend/dist /opt/depl0y/frontend/dist COPY src/frontend/dist /opt/depl0y/frontend/dist
COPY deployment/docker/combined/nginx.conf /etc/nginx/conf.d/default.conf
# Default environment values (can be overridden at runtime) # Default environment values (can be overridden at runtime)
ENV DATABASE_URL=sqlite:////var/lib/depl0y/db/depl0y.db \ ENV DATABASE_URL=sqlite:////var/lib/depl0y/db/depl0y.db \
@@ -2,6 +2,7 @@
set -e set -e
APP_PORT="${APPLICATION_PORT_INTERNAL:-8080}" APP_PORT="${APPLICATION_PORT_INTERNAL:-8080}"
BACKEND_PORT="${BACKEND_PORT_INTERNAL:-8000}"
# Ensure core data directories exist (may be bind-mounted) # Ensure core data directories exist (may be bind-mounted)
mkdir -p /var/lib/depl0y/db \ mkdir -p /var/lib/depl0y/db \
@@ -27,6 +28,9 @@ echo "Ensuring default admin user exists..."
python /opt/depl0y/backend/init_admin_user.py || echo "Warning: admin user initialization failed" python /opt/depl0y/backend/init_admin_user.py || echo "Warning: admin user initialization failed"
echo "Admin user initialization step completed." echo "Admin user initialization step completed."
echo "Starting Depl0y with uvicorn on port ${APP_PORT}..." echo "Starting Depl0y backend (uvicorn) on port ${BACKEND_PORT} and nginx on port ${APP_PORT}..."
exec uvicorn app.main:app --host 0.0.0.0 --port "${APP_PORT}" uvicorn app.main:app --host 127.0.0.1 --port "${BACKEND_PORT}" &
echo "Starting nginx..."
exec nginx -g "daemon off;"
+37
View File
@@ -0,0 +1,37 @@
server {
listen 8080;
server_name _;
client_max_body_size 10G;
# Frontend
location / {
root /opt/depl0y/frontend/dist;
try_files $uri $uri/ /index.html;
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
# Backend API
location /api {
proxy_pass http://127.0.0.1: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;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
access_log /var/log/nginx/depl0y_access.log;
error_log /var/log/nginx/depl0y_error.log;
}
+17
View File
@@ -5,8 +5,25 @@ server {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html; index index.html;
# Frontend SPA
location / { location / {
try_files $uri /index.html; try_files $uri /index.html;
} }
# Backend API - expects a backend service reachable at http://backend:8000
location /api {
proxy_pass http://backend: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;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
} }