-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.production
More file actions
39 lines (26 loc) · 940 Bytes
/
Dockerfile.production
File metadata and controls
39 lines (26 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM node:lts-alpine AS builder
# Create app directory
WORKDIR /app
COPY package*.json ./
# node-gyp dependencies
RUN apk add --no-cache --virtual python make g++ && rm -rf /var/cache/apk/*
# Install dependencies from package-lock.json
RUN npm ci --no-audit --no-fund
COPY . .
RUN npm run build
# Remove the packages specified in devDependencie
RUN npm prune --production
# By using the FROM statement again, we are telling Docker that it should create a new,
# fresh image without any connection to the previous one.
FROM node:lts AS build
# Create app directory
WORKDIR /app
COPY package*.json ./
# Copy the built /dist folder from the builder image.
# This way we are only getting the /dist directory, without the devDependencies,
# installed in our final image.
COPY --from=builder /app .
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
ENTRYPOINT [ "npm", "run" ]
CMD ["start:prod"]