This commit is contained in:
cangui 2025-08-18 19:31:09 +02:00
parent 491d35b5e1
commit 468e0bd888

View File

@ -1,29 +1,21 @@
# ---------- build ----------
FROM golang:1.24 AS builder
WORKDIR /src
RUN apk add --no-cache build-base # gcc/make/musl-dev pour cgo
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential ca-certificates && rm -rf /var/lib/apt/lists/*
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
FROM debian:bookworm-slim
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates tzdata busybox && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /out/shelfy /app/shelfy
RUN mkdir -p /app/web
COPY web /app/web
# 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
&& chmod -R 0775 /app /var/log/shelfy
ENTRYPOINT ["/bin/sh","-lc","/app/shelfy 2>&1 | tee -a /var/log/shelfy/shelfy.log"]