From 962f8cb1457514744be8a46171a9c8bdc84a3f3d Mon Sep 17 00:00:00 2001 From: danysmall Date: Sun, 13 Nov 2022 01:18:28 +0300 Subject: [PATCH] Restored original develop Dockerfile --- Dockerfile | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec52764..9a98d4f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,30 @@ -# Install dependencies of project -FROM node:fermium-alpine AS dependencies +# Install dependencies only when needed +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 WORKDIR /home/app/ -COPY package.json ./ -RUN npm i +COPY package.json package-lock.json ./ +RUN npm ci -# Build application to bunch of static files -FROM node:fermium-alpine AS builder -WORKDIR /home/app/ -COPY --from=dependencies ./home/app/node_modules ./node_modules -COPY . . -RUN npm run build +# Bundle static assets with nginx +FROM node:fermium-alpine as production - -# NGINX image -FROM nginx:1.21.6 as production # Copy built assets from builder -COPY --from=builder /home/app/build /usr/share/nginx/html -# Add nginx.config -COPY nginx.conf /etc/nginx/conf.d/default.conf -# Copy setup nginx entrypoint file -COPY ./scripts/entrypoint.sh . +WORKDIR /home/app/ +COPY --from=deps ./home/app/node_modules ./node_modules +COPY . . # Expose ports -EXPOSE 80 - -# Execute script -RUN chmod +x ./entrypoint.sh +EXPOSE 3000 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 \ -# && addgroup --g ${GROUP_UID} -S ${GROUP_NAME} \ -# && adduser -D -S -s /sbin/nologin -u ${USER_UID} -G ${GROUP_NAME} ${USER_NAME} -# USER "${USER_NAME}" +RUN 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} +USER "${USER_NAME}" -ENTRYPOINT ["./entrypoint.sh"] -# Start serving -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +ENTRYPOINT [ "npm","start"] \ No newline at end of file