shelfy-v2/Dockerfile

28 lines
861 B
Docker
Raw Normal View History

2025-08-18 17:07:50 +00:00
# ---------- build ----------
FROM golang:1.22-alpine AS builder
2025-08-18 17:04:02 +00:00
WORKDIR /src
2025-08-18 17:07:50 +00:00
RUN apk add --no-cache build-base # gcc/make/musl-dev pour cgo
2025-07-27 14:26:30 +00:00
COPY go.mod go.sum ./
RUN go mod download
COPY . .
2025-08-18 17:07:50 +00:00
# Si ton main est à la racine : "."
# Sinon remplace le dernier "." par le chemin du package main.
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o /out/shelfy .
2025-07-27 14:26:30 +00:00
2025-08-18 17:07:50 +00:00
# ---------- runtime ----------
2025-08-18 17:04:02 +00:00
FROM alpine:3.20
2025-08-18 17:07:50 +00:00
# utilitaires utiles (shell, certificats, timezone)
RUN apk add --no-cache ca-certificates tzdata
2025-08-18 17:04:02 +00:00
WORKDIR /app
COPY --from=builder /out/shelfy /app/shelfy
2025-08-18 17:07:50 +00:00
# Prépare les répertoires (DB, upload, logs)
RUN mkdir -p /app/data /app/upload /var/log/shelfy \
&& chmod -R 0775 /var/log/shelfy /app
# Lance l'appli et duplique les logs vers un fichier pour Fail2ban
ENTRYPOINT ["/bin/sh","-lc","/app/shelfy 2>&1 | tee -a /var/log/shelfy/shelfy.log"]