-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
85 lines (66 loc) · 2 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
#######################
# Step 1: Base target #
#######################
FROM node:18-alpine3.17 as base
ARG http_proxy
ARG https_proxy
ARG no_proxy
ARG npm_registry
ARG NPM_LATEST
RUN apk add curl
# use proxy & private npm registry
RUN if [ ! -z "$http_proxy" ] ; then \
npm config delete proxy; \
npm config set proxy $http_proxy; \
npm config set https-proxy $https_proxy; \
npm config set no-proxy $no_proxy; \
fi ; \
[ -z "$npm_registry" ] || npm config set registry=$npm_registry
RUN [ -z "${NPM_LATEST}" ] || npm i npm@latest -g
################################
# Step 2: "development" target #
################################
FROM base as development
ARG NPM_FIX
ARG NPM_VERBOSE
ARG APP_ID
ARG API_PORT
ENV APP_ID=${APP_ID}
ENV API_PORT=${API_PORT}
ENV NPM_CONFIG_LOGLEVEL debug
WORKDIR /home/node/
USER node
COPY package.json ./
RUN if [ -z "${NPM_VERBOSE}" ]; then\
npm install; \
else \
npm install --verbose; \
fi
VOLUME /${APP_ID}/src
COPY jestconfig.json .eslintrc.json ./
# Expose the listening port of your app
EXPOSE ${API_PORT}
CMD ["npm","run", "dev"]
###############################
# Step 3: "production" target #
###############################
FROM base as production
ARG NPM_AUDIT_DRY_RUN
ENV APP_ID=judilibre-search
ENV API_PORT=8080
ENV NODE_ENV=production
WORKDIR /home/node/
COPY package.json package-lock.json ./
RUN chown node package-lock.json
USER node
# Install production dependencies and clean cache
RUN npm install --production
RUN npm config set audit-level moderate
#RUN npm audit --json --registry=https://registry.npmjs.org || ${NPM_AUDIT_DRY_RUN:-false} && \
RUN npm cache clean --force
ADD src/ ./src
# Expose the listening port of your app
EXPOSE ${API_PORT}
# HEALTHCHECK --interval=5m --timeout=2m --start-period=45s \
# CMD curl -f --silent --retry 6 --max-time 5 --retry-delay 10 --retry-max-time 60 "http://localhost:${API_PORT}/healthcheck" || bash -c 'kill -s 15 -1 && (sleep 10; kill -s 9 -1)'
CMD ["node","./src"]