Fix nginx permission issue for non-root container
Some checks failed
Build and Push to Harbor / build-and-push (push) Has been cancelled

This commit is contained in:
Neon Vortex
2025-11-21 20:00:42 -05:00
parent 68d09fff18
commit f947438a7d

View File

@@ -10,12 +10,14 @@ COPY nginx.conf /etc/nginx/conf.d/neon-vortex.conf
# Copy application files
COPY . /usr/share/nginx/html/
# Create a non-root user for nginx
# Create a non-root user for nginx and setup writable directories
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
mkdir -p /run && \
touch /run/nginx.pid && \
chown -R nginx:nginx /run/nginx.pid && \
chmod 755 /run
# Switch to non-root user
USER nginx