-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Dockerfile
56 lines (40 loc) · 1.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
### Baseline image for development/test/build ###
# We require a lot of extras for building (Python, GCC) because of Node-Zopfli.
FROM node:18.20.4 as dev
LABEL maintainer="[email protected]"
RUN mkdir -p /app
WORKDIR /app
# Copy dependencies only so they can be cached.
COPY package.json package-lock.json ./
# Install deps.
RUN npm ci
# Finally, pull in the source.
# TODO: can we mount so this can be used for live-reload dev?
COPY . .
CMD ["/bin/bash"]
### Build a production version of the app ###
# Note this *creates* production artifacts. The docker image created here
# should never actually be distributed; it's just an intermediate.
FROM dev as build
ENV NODE_ENV=production
RUN npm run build-production
### Release Image ###
# It might feel ridiculous to build up all the same things again, but the
# resulting image is less than half the size!
FROM node:18.20.4-slim as release
LABEL maintainer="[email protected]"
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init
ENV NODE_ENV=production
RUN mkdir -p /app
WORKDIR /app
# Copy dependencies only so they can be cached.
COPY package.json package-lock.json ./
EXPOSE 3001
# Install deps.
RUN npm ci --only=production
# Now copy all source.
COPY . .
COPY --from=build /app/dist ./dist
# Run server. Use dumb-init because Node does not handle Docker's stop signal.
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "run", "start"]