-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathDockerfile
93 lines (73 loc) · 2.42 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# 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/sdk-scheme-adapter:local \
# . \
#
# Build Image
FROM node:${NODE_VERSION} AS builder
## Install tool dependencies
RUN apk add --no-cache -t build-dependencies make gcc g++ python3 libtool openssl-dev autoconf automake yarn bash
## Install & Setup LibrdKafka Lib for Builder
RUN apk add --no-cache librdkafka-dev
ENV BUILD_LIBRDKAFKA=0
WORKDIR /opt/app
## Copy Root files
COPY ./package.json .
COPY ./yarn.lock .
COPY ./.yarnrc.yml .
COPY ./.yarn/releases/ ./.yarn/releases/
COPY ./.yarn/plugins/ ./.yarn/plugins/
COPY ./.nvmrc .
COPY ./nx.json .
COPY ./tsconfig.json .
## Copy Package.json for each module
## TODO: Dynamically pull in package.json
COPY ./modules/api-svc/package.json ./modules/api-svc/package.json
COPY ./modules/outbound-command-event-handler/package.json ./modules/outbound-command-event-handler/package.json
COPY ./modules/outbound-domain-event-handler/package.json ./modules/outbound-domain-event-handler/package.json
COPY ./modules/private-shared-lib/package.json ./modules/private-shared-lib/package.json
## Install dependencies
RUN yarn install --immutable
# Build Run-time image
FROM node:${NODE_VERSION}
WORKDIR /opt/app
## Install general dependencies
RUN apk add --no-cache bash yarn
## Install & Setup LibrdKafka Lib for Runtime
RUN apk add --no-cache librdkafka
ARG BUILD_DATE
ARG VCS_URL=https://github.com/mojaloop/sdk-scheme-adapter
ARG VCS_REF
ARG VERSION=latest
## See http://label-schema.org/rc1/ for label schema info
LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="sdk-scheme-adapter"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.vcs-url=$VCS_URL
LABEL org.label-schema.vcs-ref=$VCS_REF
LABEL org.label-schema.url="https://mojaloop.io/"
LABEL org.label-schema.version=$VERSION
## Create a non-root user: ml-user
RUN adduser -D ml-user
## Create ml-user
USER ml-user
## Update permissions for ml-user
COPY --chown=ml-user --from=builder /opt/app .
## Copy over any src changes
COPY --chown=ml-user ./modules/ ./modules/
## Run any build scripts
RUN yarn run build
## Expose ports
### INBOUND API PORT
EXPOSE 4000
### OUTBOUND API PORT
EXPOSE 4001
### TEST API PORT
EXPOSE 4002
## Set default run command
CMD ["yarn", "run", "start"]