Dockerfile changes
This commit is contained in:
parent
07c4ae8cbd
commit
8d6a9ab74c
27
Dockerfile
27
Dockerfile
@ -17,22 +17,25 @@ COPY . .
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Bundle static assets with nginx
|
# Bundle static assets with nginx
|
||||||
FROM nginx:1.21.6 as production
|
FROM node:16-alpine as production
|
||||||
# Copy built assets from builder
|
# Copy built assets from builder
|
||||||
COPY --from=builder /app/build /usr/share/nginx/html
|
WORKDIR /app
|
||||||
# Add nginx.config
|
COPY --from=builder /app/build .
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
# Expose ports
|
# Expose ports
|
||||||
EXPOSE 80
|
EXPOSE 3000
|
||||||
|
|
||||||
COPY entrypoint.sh .
|
|
||||||
COPY .env.production .
|
COPY .env.production .
|
||||||
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
ENV USER_NAME=node_user USER_UID=2000 GROUP_NAME=node_group GROUP_UID=2000
|
||||||
|
|
||||||
# Execute script
|
RUN npm i -g serve \
|
||||||
RUN ["chmod", "+x", "./entrypoint.sh"]
|
&& deluser --remove-home node \
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
&& 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 .
|
Loading…
x
Reference in New Issue
Block a user