-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dockerfile
88 lines (64 loc) · 2.39 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
#
# ---- Base ----
FROM node:18-alpine3.18 as base
# Create app directory
WORKDIR /usr/src/app
# Expose the port to the Docker instance (not the host!)
EXPOSE 4000
RUN apk add --no-cache \
bash=5.2.15-r5
#
# ---- Development Dependencies ----
FROM base AS developmentdependencies
# Installs Git and packages required for Puppeteer
# https://pkgs.alpinelinux.org/packages
RUN apk add --no-cache \
chromium=119.0.6045.159-r0 \
freetype=2.13.0-r5 \
freetype-dev=2.13.0-r5 \
harfbuzz=7.3.0-r0 \
ca-certificates=20240226-r0
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Copy all files, except those ignored by .dockerignore, to the container
COPY . .
# Installs modules from package-lock.json if there are changes, this ensures reproducible build
RUN npm --silent ci
#
# ---- Development ----
FROM developmentdependencies AS development
# Run start script as specified in package.json
CMD [ "/opt/wait-for-it.sh", "-t", "0", "database:3306", "--", "npm", "run", "start:dev" ]
#
# ---- Test ----
FROM developmentdependencies AS test
# Run start script as specified in package.json
CMD [ "/opt/wait-for-it.sh", "-t", "0", "database:3306", "--", "npm", "run", "test" ]
#
# ---- Test parallel for CI ----
FROM developmentdependencies AS test_parallel_ci
CMD [ "sh", "-c", "/opt/wait-for-it.sh -t 0 test_db:3306 -- npm run test:subset" ]
#
# ---- Test parallel local ----
FROM developmentdependencies AS test_parallel_local
CMD [ "sh", "-c", "/opt/wait-for-it.sh -t 0 test_db:3306 -- npm run test:subset-local" ]
#
# ---- Coverage ----
FROM developmentdependencies AS coverage
# Run start script as specified in package.json
CMD [ "/opt/wait-for-it.sh", "-t", "0", "database:3306", "--", "npm", "run", "coverage" ]
#
# ---- Production Dependencies ----
FROM base AS productiondependencies
# Copy package.json and package-lock.json to the container
COPY package*.json ./
# Installs modules from package-lock.json, this ensures reproducible build
RUN npm --silent ci --production
# Copy all files, except those ignored by .dockerignore, to the container
COPY ./lib ./lib
#
# ---- Production ----
FROM productiondependencies AS production
# Run start script as specified in package.json
CMD [ "/opt/wait-for-it.sh", "-t", "0", "database:3306", "--", "node", "lib/main.js" ]