-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
66 lines (46 loc) · 1.68 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
# syntax=docker/dockerfile:1
FROM node:12-buster as base
LABEL maintainer="Christian Koop <[email protected]>"
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config xvfb -y && \
npm i -g npm --update-notifier false && \
npm cache clean --force
RUN mkdir -p /app/storage/ /app/logs/ && \
chown -R node:node /app/
WORKDIR /app/
USER node
COPY --chown=node:node LICENSE README.md ./
COPY --chown=node:node package.json package-lock.json ./
##
# Builder: Compiles the project into js files (optionally generates source maps too)
##
FROM base as builder
ARG BUILD_SCRIPT=build
RUN npm ci
COPY --chown=node:node tsconfig.json ./tsconfig.json
COPY --chown=node:node src/ ./src/
RUN npm run $BUILD_SCRIPT
##
# Development: Copies the resources, compiled js files and source maps and starts the application with source map support
##
FROM base as dev
# TODO: Check if volume mounts could be beneficial for development
RUN npm ci
COPY --chown=node:node --from=builder /app/build/ ./build/
COPY --chown=node:node resources/ ./resources/
CMD ["npm", "run", "start-headless"]
##
# Production: Copies the resources and compiled js files and starts the application
##
FROM base as prod
# TODO: This heavily relies on hostname being set and the default port 8080 being used
HEALTHCHECK --interval=1m --timeout=30s --retries=3 \
CMD wget --spider $(hostname):8091
ENV NODE_ENV=production
RUN npm ci && \
npm cache clean --force && \
rm -Rf /home/node/.npm/
COPY --chown=node:node --from=builder /app/build/ ./build/
COPY --chown=node:node resources/ ./resources/
CMD ["npm", "run", "start-headless"]