Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
94 lines (74 loc) · 2.81 KB
/
Copy pathDockerfile
File metadata and controls
94 lines (74 loc) · 2.81 KB
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
89
90
91
92
93
94
# ----------------------------------------
# 1. Build du frontend Angular
# ----------------------------------------
FROM node:22-alpine AS ng-builder
WORKDIR /app
COPY ng_web/package*.json ./
RUN npm install
COPY ng_web/ ./
RUN npm run build -- --configuration production
# ----------------------------------------
# 2. Build du backend Go
# ----------------------------------------
FROM golang:1.25-alpine AS builder
# Installer les dépendances de build
RUN apk add --no-cache git make ca-certificates wget tar xz
WORKDIR /app
# Copier les fichiers de dépendances
COPY go.mod go.sum ./
RUN go mod download
# Copier le code source
COPY . .
# Builder le serveur
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /bin/fx-server ./cmd/server
# ----------------------------------------
# 3. Image finale légère
# ----------------------------------------
FROM alpine:latest
# Installer les dépendances runtime et quelques polices standard
# Installer les dépendances runtime et quelques polices standard.
# Familles disponibles ensuite pour Typst : Liberation Sans/Serif/Mono,
# DejaVu Sans/Serif/Sans Mono, Open Sans, Noto Sans/Serif (font-noto).
RUN apk add --no-cache ca-certificates tzdata fontconfig ttf-liberation ttf-dejavu ttf-opensans font-noto
# Installer Typst
ARG TYPST_VERSION=0.15.0
RUN wget https://github.com/typst/typst/releases/download/v${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz \
&& tar xf typst-x86_64-unknown-linux-musl.tar.xz \
&& mv typst-x86_64-unknown-linux-musl/typst /usr/local/bin/ \
&& rm -rf typst-* \
&& chmod +x /usr/local/bin/typst
# Créer un utilisateur non-root
RUN addgroup -g 1000 fx && \
adduser -D -u 1000 -G fx fx
# Copier le binaire depuis le builder
COPY --from=builder /bin/fx-server /usr/local/bin/fx-server
# Copier les templates embarqués (si nécessaire)
COPY --from=builder /app/pkg/pdf/templates /templates
# Copier le dossier docs (pour le schéma JSON)
COPY --from=builder /app/docs/invoice.schema.json /docs
# Copier le frontend Angular compilé
COPY --from=ng-builder /app/dist/ng_web/browser /web/ng
# Créer les répertoires nécessaires
RUN mkdir -p /storage /templates-custom /web/ng && \
chown -R fx:fx /storage /templates-custom /web/ng
# Changer vers l'utilisateur non-root
USER fx
# Variables d'environnement par défaut
ENV PORT=8080 \
HOST=0.0.0.0 \
STORAGE_TYPE=local \
STORAGE_LOCAL_PATH=/storage \
WEB_UI_ENABLED=true \
WEB_UI_PATH=/web/ng \
READ_TIMEOUT=30 \
WRITE_TIMEOUT=30 \
SHUTDOWN_TIMEOUT=5 \
ALLOW_CUSTOM_TEMPLATES=false \
TYPST_ROOT=/
# Exposer le port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/api/v1/health || exit 1
# Démarrer le serveur
CMD ["fx-server"]