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