-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
44 lines (35 loc) · 1.12 KB
/
Dockerfile
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
40
41
42
43
44
ARG NODE_VERSION=16.14.0
########################
# Builder stage
#
FROM node:${NODE_VERSION}-alpine AS builder
WORKDIR /app
# App build dependencies
# This step is done before copying and building the app source code
# to benefit from Docker layer caching if the dependencies have not changed
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
RUN npm ci --quiet
# Copy source code and build
COPY ./ ./
RUN npm run build
########################
# Final image
#
FROM node:${NODE_VERSION}-alpine
WORKDIR /app
# Runtime dependencies
RUN npm install -g pm2
# App runtime dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
RUN npm ci --quiet --only=production
# Add the Instana APM layer
COPY --from=icr.io/instana/aws-fargate-nodejs:latest /instana /instana
RUN /instana/setup.sh
ENV NODE_OPTIONS="--require /instana/node_modules/@instana/aws-fargate"
# Build artifacts
COPY --from=builder /app/pm2.config.js ./pm2.config.js
COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD [ "pm2-runtime", "--json", "pm2.config.js" ]