-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
64 lines (44 loc) · 1.61 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
# syntax=docker/dockerfile:1
FROM node:22-alpine as base
LABEL maintainer="Christian Koop <contact@sprax2013.de>"
RUN apk --no-cache -U upgrade && \
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 clean-install
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 clean-install
COPY --chown=node:node --from=builder /app/dist/ ./dist/
COPY --chown=node:node resources/ ./resources/
CMD ["node", "--enable-source-maps", "dist/index.js"]
##
# 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):8080
ENV NODE_ENV=production
RUN npm clean-install && \
npm cache clean --force && \
rm -Rf /home/node/.npm/
COPY --chown=node:node --from=builder /app/dist/ ./dist/
COPY --chown=node:node resources/ ./resources/
CMD ["node", "dist/index.js"]