Restored original develop Dockerfile

This commit is contained in:
Daniel Weissmall 2022-11-13 01:18:28 +03:00
parent d755be1f95
commit 962f8cb145

View File

@ -1,43 +1,30 @@
# Install dependencies of project # Install dependencies only when needed
FROM node:fermium-alpine AS dependencies FROM node:fermium-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat RUN apk add --no-cache libc6-compat
WORKDIR /home/app/ WORKDIR /home/app/
COPY package.json ./ COPY package.json package-lock.json ./
RUN npm i RUN npm ci
# Build application to bunch of static files # Bundle static assets with nginx
FROM node:fermium-alpine AS builder FROM node:fermium-alpine as production
WORKDIR /home/app/
COPY --from=dependencies ./home/app/node_modules ./node_modules
COPY . .
RUN npm run build
# NGINX image
FROM nginx:1.21.6 as production
# Copy built assets from builder # Copy built assets from builder
COPY --from=builder /home/app/build /usr/share/nginx/html WORKDIR /home/app/
# Add nginx.config COPY --from=deps ./home/app/node_modules ./node_modules
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY . .
# Copy setup nginx entrypoint file
COPY ./scripts/entrypoint.sh .
# Expose ports # Expose ports
EXPOSE 80 EXPOSE 3000
# Execute script
RUN chmod +x ./entrypoint.sh
ENV NODE_ENV production ENV NODE_ENV production
# ENV USER_NAME=node_user USER_UID=2000 GROUP_NAME=node_group GROUP_UID=2000 ENV USER_NAME=node_user USER_UID=2000 GROUP_NAME=node_group GROUP_UID=2000
# RUN deluser --remove-home node \ RUN deluser --remove-home node \
# && addgroup --g ${GROUP_UID} -S ${GROUP_NAME} \ && addgroup --g ${GROUP_UID} -S ${GROUP_NAME} \
# && adduser -D -S -s /sbin/nologin -u ${USER_UID} -G ${GROUP_NAME} ${USER_NAME} && adduser -D -S -s /sbin/nologin -u ${USER_UID} -G ${GROUP_NAME} ${USER_NAME}
# USER "${USER_NAME}" USER "${USER_NAME}"
ENTRYPOINT ["./entrypoint.sh"]
# Start serving ENTRYPOINT [ "npm","start"]
CMD ["nginx", "-g", "daemon off;"]