diff --git a/Dockerfile b/Dockerfile index 698b4c1..ad28909 100755 --- a/Dockerfile +++ b/Dockerfile @@ -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;"] \ No newline at end of file + +USER "${USER_NAME}" +CMD serve -s . \ No newline at end of file