Added Dockerfile

This commit is contained in:
2026-02-27 21:54:06 +01:00
parent 6289830732
commit b87fe71503
2 changed files with 26 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
appdata
.idea
*.exe
*.exe
*.cmd

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Wir sagen Docker: Der Builder soll IMMER auf der Architektur deines PCs laufen (schnell!)
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
# Cache für Module nutzen
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# buildx übergibt diese Variablen automatisch
ARG TARGETOS
ARG TARGETARCH
# Hier passiert die Magie: Go kompiliert NATIV für das Ziel (Cross-Compilation)
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -ldflags "-s -w" -o shap-planner-backend .
# Final Stage (bleibt gleich klein)
FROM scratch
COPY --from=builder /app/shap-planner-backend /shap-planner-backend
ENTRYPOINT ["/shap-planner-backend"]