Dockerfile changes

This commit is contained in:
Daniel Weissmall 2022-10-29 16:23:34 +03:00
parent 07c4ae8cbd
commit 8d6a9ab74c

View File

@ -17,22 +17,25 @@ COPY . .
RUN npm run build
# Bundle static assets with nginx
FROM nginx:1.21.6 as production
FROM node:16-alpine as production
# Copy built assets from builder
COPY --from=builder /app/build /usr/share/nginx/html
# Add nginx.config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose ports
EXPOSE 80
WORKDIR /app
COPY --from=builder /app/build .
# Expose ports
EXPOSE 3000
COPY entrypoint.sh .
COPY .env.production .
ENV NODE_ENV production
ENV USER_NAME=node_user USER_UID=2000 GROUP_NAME=node_group GROUP_UID=2000
# Execute script
RUN ["chmod", "+x", "./entrypoint.sh"]
ENTRYPOINT ["./entrypoint.sh"]
RUN npm i -g serve \
&& deluser --remove-home node \
&& addgroup --g ${GROUP_UID} -S ${GROUP_NAME} \
&& adduser -D -S -s /sbin/nologin -u ${USER_UID} -G ${GROUP_NAME} ${USER_NAME}\
&& chown -R ${USER_NAME}:${GROUP_NAME} "/app/"
# Start serving
CMD ["nginx", "-g", "daemon off;"]
USER "${USER_NAME}"
CMD serve -s .