ci: update frontend nginx config

This commit is contained in:
Darkraise
2026-02-02 17:25:37 +07:00
parent 58a48dfc91
commit 92c4e7187b
4 changed files with 55 additions and 20 deletions
+48
View File
@@ -0,0 +1,48 @@
# Main nginx configuration for Flashpoint Web Frontend
# Optimized for Docker container running as non-root user
# Don't use 'user' directive when running as non-root
# worker_processes auto is fine for most cases
worker_processes auto;
# Log to stdout/stderr for Docker (no file permission issues)
error_log /dev/stderr warn;
# PID file location (must be writable by non-root user)
pid /tmp/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
# Include mime types
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging to stdout for Docker
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout main;
# Performance optimizations
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Temp directories (must be writable by non-root user)
client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;
# Include server configurations
include /etc/nginx/conf.d/*.conf;
}
+5 -15
View File
@@ -50,8 +50,10 @@ RUN apk add --no-cache curl tzdata su-exec shadow gettext
# Copy built files from builder
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
# Copy nginx configuration
COPY frontend/nginx.conf /etc/nginx/templates/default.conf.template
# Copy nginx configuration from .nginx/ folder
# Main config: logs to stdout/stderr, uses /tmp for temp files (no permission issues)
COPY frontend/.nginx/nginx.conf /etc/nginx/nginx.conf
COPY frontend/.nginx/default.conf.template /etc/nginx/templates/default.conf.template
# Copy entrypoint script
COPY frontend/docker-entrypoint.sh /docker-entrypoint.sh
@@ -60,26 +62,14 @@ COPY frontend/docker-entrypoint.sh /docker-entrypoint.sh
ENV BACKEND_HOST=backend \
BACKEND_PORT=3100
# Create non-root user with default UID/GID 1000 (nginx:alpine doesn't have one)
# Create non-root user with default UID/GID 1000
# These can be overridden at runtime via PUID/PGID environment variables
RUN addgroup -g 1000 -S appuser && \
adduser -S appuser -u 1000 -G appuser && \
chown -R appuser:appuser /usr/share/nginx/html && \
chown -R appuser:appuser /var/cache/nginx && \
chown -R appuser:appuser /var/log/nginx && \
chown -R appuser:appuser /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \
chown -R appuser:appuser /var/run/nginx.pid && \
chmod +x /docker-entrypoint.sh
# Create necessary directories
RUN mkdir -p /var/cache/nginx/client_temp \
/var/cache/nginx/proxy_temp \
/var/cache/nginx/fastcgi_temp \
/var/cache/nginx/uwsgi_temp \
/var/cache/nginx/scgi_temp && \
chown -R appuser:appuser /var/cache/nginx
# Expose port (8080 for non-root user)
EXPOSE 8080
+2 -5
View File
@@ -60,13 +60,10 @@ setup_user() {
echo "✅ User UID/GID OK (UID=$PUID, GID=$PGID)"
fi
# Always fix ownership of nginx directories (in case of mounted volumes)
echo "🔧 Ensuring correct ownership of nginx directories..."
# Fix ownership of directories that may be mounted as volumes
echo "🔧 Ensuring correct ownership of app directories..."
chown -R $APP_USER:$APP_GROUP /usr/share/nginx/html 2>/dev/null || true
chown -R $APP_USER:$APP_GROUP /var/cache/nginx 2>/dev/null || true
chown -R $APP_USER:$APP_GROUP /var/log/nginx 2>/dev/null || true
chown -R $APP_USER:$APP_GROUP /etc/nginx/conf.d 2>/dev/null || true
chown $APP_USER:$APP_GROUP /var/run/nginx.pid 2>/dev/null || true
}
# Only setup user if running as root