-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (38 loc) · 1.24 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
45
46
47
48
49
50
51
52
# Arguments
ARG NODE_VERSION=lts-alpine
# NOTE: Ensure you set NODE_VERSION Build Argument as follows...
#
# export NODE_VERSION="$(cat .nvmrc)-alpine" \
# docker build \
# --build-arg NODE_VERSION=$NODE_VERSION \
# -t mojaloop/als-msisdn-oracle-svc:local \
# . \
#
# Build Image
FROM node:${NODE_VERSION} AS builder
USER root
WORKDIR /opt/app/
RUN apk add --no-cache -t build-dependencies git make gcc g++ python3 libtool autoconf automake \
&& cd $(npm root -g)/npm
COPY package.json package-lock.json* /opt/app/
RUN npm ci
# Check in .dockerignore what is skipped during copy
COPY /. /opt/app/
RUN npm run build
# Cleanup
RUN apk del build-dependencies
FROM node:${NODE_VERSION}
WORKDIR /opt/app/
# Create empty log file & link stdout to the application log file
RUN mkdir ./logs && touch ./logs/combined.log
RUN ln -sf /dev/stdout ./logs/combined.log
# Create a non-root user: app-user
RUN adduser -D app-user
USER app-user
# Copy only essential files for running service
COPY --chown=app-user --from=builder /opt/app/node_modules ./node_modules
COPY --chown=app-user --from=builder /opt/app/package*.json ./
COPY --chown=app-user --from=builder /opt/app/dist ./dist
RUN npm prune --production
EXPOSE 3000
CMD ["npm", "run", "start"]