Build ui for prod

This commit is contained in:
2025-04-14 22:55:32 -04:00
parent c4ac1ff14d
commit 9ad87fbac5
15 changed files with 367 additions and 18456 deletions

View File

@@ -1,6 +1,30 @@
FROM node:18-alpine AS ui-builder
RUN apk add --no-cache libc6-compat
WORKDIR /builder
COPY ui/ ./
RUN ls
RUN \
pwd && \
if [ -f package.json ]; then \
npm i && \
npm run build; \
else \
echo "package.json not found." && \
exit 2; \
fi
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
COPY templates/ /templates/
COPY scripts/01-configure_ssh.sh /docker-entrypoint.d/01-configure_ssh.sh
ARG environment
ENV environment=${environment}
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/templates/ /templates/
COPY nginx/scripts/01-configure_ssh.sh /docker-entrypoint.d/01-configure_ssh.sh
COPY --from=ui-builder /builder/dist /dist
RUN echo "Copying UI assets into nginx html folder..."; \
mkdir -p /usr/share/nginx/html && \
cp -R /dist/* /usr/share/nginx/html;
RUN chmod +x /docker-entrypoint.d/01-configure_ssh.sh

View File

@@ -5,8 +5,18 @@ mkdir -p /etc/nginx/templates
if [ "$NGINX_SSL_ENABLED" = "true" ]; then
echo "Using SSL configuration"
cp /templates/ssl.conf.template /etc/nginx/templates/default.conf.template
cp /templates/ssl.conf.template /templates/default.conf.template
else
echo "Using non-SSL configuration"
cp /templates/nossl.conf.template /etc/nginx/templates/default.conf.template
cp /templates/nossl.conf.template /templates/default.conf.template
fi
if [ "$ENVIRONMENT" = "production" ]; then
export UI_ROOT="/usr/share/nginx/html"
echo "Setting production root to ${UI_ROOT}"
else
export UI_ROOT="/home"
echo "Setting development root to ${UI_ROOT}"
fi
envsubst '$UI_ROOT' < /templates/default.conf.template > /etc/nginx/templates/default.conf.template

View File

@@ -20,9 +20,15 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
}
# Reverse proxy for the UI and default catch-all
# Serve static files if they exist, otherwise proxy to the UI backend
location / {
proxy_pass http://${NGINX_INTERNAL_HOST}:${UI_PORT}/;
root ${UI_ROOT};
try_files $uri /index.html @ui_backend;
}
# Fallback to proxying for UI requests
location @ui_backend {
proxy_pass http://${NGINX_INTERNAL_HOST}:${UI_PORT};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View File

@@ -40,9 +40,15 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
}
# Reverse proxy for the UI and default catch-all
# Serve static files if they exist, otherwise proxy to the UI backend
location / {
proxy_pass http://${NGINX_INTERNAL_HOST}:${UI_PORT}/;
root ${UI_ROOT};
try_files $uri /index.html @ui_backend;
}
# Fallback to proxying for UI requests
location @ui_backend {
proxy_pass http://${NGINX_INTERNAL_HOST}:${UI_PORT};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;