Skip to content

Commit

Permalink
build: make docker root-less
Browse files Browse the repository at this point in the history
  • Loading branch information
Caouissin Laurent authored and Caouissin Laurent committed May 3, 2024
1 parent a14be3b commit 3f50c60
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
FROM nginx
RUN rm -rf /usr/share/nginx/html/*
FROM nginxinc/nginx-unprivileged:1.25-alpine

ADD build /usr/share/nginx/html
# Non root user
ENV NGINX_USER_ID=101
ENV NGINX_GROUP_ID=101
ENV NGINX_USER=nginx

RUN rm etc/nginx/conf.d/default.conf
COPY ./nginx.conf /etc/nginx/conf.d/
USER $NGINX_USER_ID

# Add build to nginx root webapp
COPY --chown=$NGINX_USER:$NGINX_USER build /usr/share/nginx/html

# Copy nginx configuration
RUN rm etc/nginx/conf.d/default.conf
COPY --chown=$NGINX_USER:$NGINX_USER nginx.conf etc/nginx/conf.d/

COPY entrypoint.sh /entrypoint.sh
# Add entrypoint
COPY --chown=$NGINX_USER:$NGINX_USER entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]

Expand Down

0 comments on commit 3f50c60

Please sign in to comment.