From b87fe7150371f2e2ea6675a7e32c5762dae31bf9 Mon Sep 17 00:00:00 2001 From: "Maurice L." Date: Fri, 27 Feb 2026 21:54:06 +0100 Subject: [PATCH] Added Dockerfile --- .gitignore | 3 ++- Dockerfile | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 95e2b2b..3584e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ appdata .idea -*.exe \ No newline at end of file +*.exe +*.cmd \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7cae24c --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file