Restored original develop Dockerfile
This commit is contained in:
parent
d755be1f95
commit
962f8cb145
47
Dockerfile
47
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;"]
|
||||
ENTRYPOINT [ "npm","start"]
|
Loading…
x
Reference in New Issue
Block a user