-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Dockerfile
81 lines (61 loc) · 1.71 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
# Stage 1
ARG BUILD_FROM=amd64/alpine:3.18
FROM node:20-alpine AS BUILD_IMAGE
# Install dependencies
RUN apk update && \
apk add --no-cache git && \
rm -rf /var/cache/apk/*
# Create working directory
RUN mkdir -p /usr/src/app && chown -R node:node /usr/src/app
# Configure user
USER node:node
# Working directory
WORKDIR /usr/src/app
# Force cache invalidation
ADD https://api.github.com/repos/congatudo/Congatudo/git/refs/heads/master /usr/src/version.json
# Download valetudo
RUN git clone --depth 1 https://github.com/congatudo/Congatudo --single-branch .
# Build environment
ENV NODE_ENV=production
ENV PKG_CACHE_PATH=./build_dependencies/pkg
# Install dependencies
RUN npm ci --production=false
# Build openapi schema
RUN npm run build_openapi_schema
# Build frontend
RUN npm run build --workspace=frontend
# Build args
ARG PKG_TARGET=node20-linuxstatic-x64
ARG PKG_OPTIONS=expose-gc,max-heap-size=64
# Build binary
RUN npx pkg \
--targets "${PKG_TARGET}" \
--compress Brotli \
--no-bytecode \
--public-packages "*" \
--options "${PKG_OPTIONS}" \
--output ./build/valetudo \
backend
# Stage 2
FROM ${BUILD_FROM}
# Install dependencies
RUN apk update && \
apk add --no-cache dumb-init && \
rm -rf /var/cache/apk/*
# Configure user
RUN addgroup -S node && adduser -S node -G node
RUN mkdir -p /etc/valetudo && chown -R node:node /etc/valetudo
USER node:node
# Working directory
WORKDIR /usr/local/bin
# Copy from build image
COPY --chown=node:node --from=BUILD_IMAGE /usr/src/app/build/valetudo ./valetudo
# Exposed ports
EXPOSE 8080
EXPOSE 4010 4030 4050
# Run environment
ENV LANG C.UTF-8
ENV VALETUDO_CONFIG_PATH=/etc/valetudo/config.json
ENV NODE_ENV=production
# Run binary
CMD ["dumb-init", "valetudo"]