This repository was archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (47 loc) · 1.35 KB
/
Dockerfile
File metadata and controls
61 lines (47 loc) · 1.35 KB
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
# Base layer
# ===============================
FROM node:16 AS node
ARG NPM_TOKEN=""
ARG INIT_SRC=/usr/local/bin/dumb-init
ARG INIT_REPO=https://github.com/Yelp/dumb-init
ENV NPM_TOKEN="$NPM_TOKEN"
RUN wget -O $INIT_SRC "$INIT_REPO/releases/download/v1.2.2/dumb-init_1.2.2_amd64" && \
chmod +x $INIT_SRC && \
mkdir /app && chown node:node /app
WORKDIR /app
USER node
EXPOSE 9001
# Manifest Cache Layer
# ===============================
FROM node AS cache
COPY --chown=node:node . /tmp
# save yarn.lock and package.json files in the cache layer
RUN mkdir /tmp/cache && \
find /tmp -type f \
\( -name "yarn.lock" -o -name "package.json" \) \
-exec cp --parents "{}" /tmp/cache \;
# Build Layer
# ===============================
FROM cache AS build
COPY --chown=node:node --from=cache /tmp/cache/* .
COPY .npmrc .npmrc
RUN yarn
RUN rm -rf .npmrc
COPY --chown=node:node . .
# Development Image
# ===============================
FROM build AS development
ENTRYPOINT ["./node_modules/.bin/nodemon"]
CMD ["index.js"]
# Test Image
# ===============================
FROM build AS test
RUN yarn run lint && \
yarn run test
# Final production image
# ===============================
FROM test AS production
RUN rm -fr node_modules && \
yarn install --production --frozen-lockfile
ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
CMD ["node", "index.js"]