Fix nginx permission issue for non-root container
Some checks failed
Build and Push to Harbor / build-and-push (push) Has been cancelled
Some checks failed
Build and Push to Harbor / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -10,12 +10,14 @@ COPY nginx.conf /etc/nginx/conf.d/neon-vortex.conf
|
|||||||
# Copy application files
|
# Copy application files
|
||||||
COPY . /usr/share/nginx/html/
|
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 && \
|
RUN chown -R nginx:nginx /usr/share/nginx/html && \
|
||||||
chown -R nginx:nginx /var/cache/nginx && \
|
chown -R nginx:nginx /var/cache/nginx && \
|
||||||
chown -R nginx:nginx /var/log/nginx && \
|
chown -R nginx:nginx /var/log/nginx && \
|
||||||
touch /var/run/nginx.pid && \
|
mkdir -p /run && \
|
||||||
chown -R nginx:nginx /var/run/nginx.pid
|
touch /run/nginx.pid && \
|
||||||
|
chown -R nginx:nginx /run/nginx.pid && \
|
||||||
|
chmod 755 /run
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER nginx
|
USER nginx
|
||||||
|
|||||||
Reference in New Issue
Block a user