Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Run container as user(nginx) with limited permissions (#81)
Browse files Browse the repository at this point in the history
* Run container as user with limited permissions

* Remove useless comments
  • Loading branch information
Andilun authored Sep 29, 2023
1 parent da60af1 commit e50ff64
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# Build stage
FROM nginx:1.24-alpine

RUN apk update \
&& apk upgrade \
&& apk add --no-cache nodejs yarn \
&& yarn global add @beam-australia/react-env \
&& apk del curl
RUN apk update && apk upgrade && \
apk add --no-cache nodejs yarn && \
yarn global add @beam-australia/react-env && \
apk del curl

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY .env docker-entrypoint.sh /var/
COPY /build /usr/share/nginx/html


# Change ownership and permissions for NGINX directories
RUN chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid && \
chown -R nginx:nginx /usr/share/nginx/html/__ENV.js

USER nginx

EXPOSE 8180

ENTRYPOINT ["sh", "/var/docker-entrypoint.sh"]

CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]

0 comments on commit e50ff64

Please sign in to comment.