-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
65 lines (47 loc) · 1.47 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
FROM node:lts-alpine as builder
ENV NPM_CONFIG_PREFIX '/home/node/.npm-global'
ENV PATH "${NPM_CONFIG_PREFIX}/bin:${PATH}"
ADD https://raw.githubusercontent.com/fdemmer/wait-for/2c082fc/wait-for /bin/wait_for_it.sh
# Install OS dependencies
RUN apk --no-cache --virtual build-dependencies add \
git \
python3 \
build-base \
libcrypto3 \
netcat-openbsd \
&& printf '%s' "${NODE_VERSION}" > /env.node
USER node
RUN mkdir /home/node/rest-api
WORKDIR /home/node/rest-api
# Transfer from the current directory (outside Docker) to inside Docker
ADD --chown=node:node . .
# Install Node.js application dependencies, both local and global
RUN npm i -g npm \
&& npm i -g \
bunyan \
mocha \
node-gyp \
tslint \
typings \
typescript \
&& typings install \
&& npm ci \
&& tsc
FROM alpine:latest as app
ENV RDBMS_URI ''
ENV REDIS_HOST 'localhost'
ENV REDIS_PORT 6379
ENV NPM_CONFIG_PREFIX '/home/node/.npm-global'
ENV PATH "${NPM_CONFIG_PREFIX}/bin:${PATH}"
COPY --from=builder /env.node /env.node
RUN addgroup -S node -g 998 \
&& adduser -S -G node -u 998 node \
&& apk --no-cache add nodejs # ="`cat /env.node`-r0"
USER node
RUN mkdir /home/node/rest-api
WORKDIR /home/node/rest-api
# Install global Node.js dependencies
COPY --from=builder --chown=node:node /home/node/.npm-global /home/node/.npm-global
# Copy over the app
COPY --from=builder --chown=node:node /home/node/rest-api .
ENTRYPOINT ["/usr/bin/node", "main.js"]