# ---------- build ---------- FROM golang:1.22-alpine AS builder WORKDIR /src RUN apk add --no-cache build-base # gcc/make/musl-dev pour cgo COPY go.mod go.sum ./ RUN go mod download COPY . . # 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 . # ---------- runtime ---------- FROM alpine:3.20 # utilitaires utiles (shell, certificats, timezone) RUN apk add --no-cache ca-certificates tzdata WORKDIR /app COPY --from=builder /out/shelfy /app/shelfy # 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"]