diff --git a/Backend/Dockerfile b/Backend/Dockerfile index 2ebbeda..098f454 100644 --- a/Backend/Dockerfile +++ b/Backend/Dockerfile @@ -1,12 +1,21 @@ -FROM golang:alpine +# syntax=docker/dockerfile:1 +FROM --platform=$BUILDPLATFORM golang:alpine AS build +ARG TARGETOS +ARG TARGETARCH +ENV CGO_ENABLED=0 \ + GOOS=$TARGETOS \ + GOARCH=$TARGETARCH WORKDIR /app - COPY go.mod go.sum /app/ - RUN go mod download && go mod verify COPY . . -RUN go build -o /usr/local/bin/app +RUN go build -o server . -CMD ["app"] +FROM alpine +WORKDIR /app +COPY --from=build /app/server /app/server + +COPY /static /app/static +ENTRYPOINT ["./server"] diff --git a/Jenkinsfile b/Jenkinsfile index e52d22e..ee0171f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,22 +16,9 @@ pipeline { } } steps { - sh 'make build_backend' + sh 'make backend' } } - stage('Deploying image arbeitszeit-backend') { - when { - anyOf{ - changeset 'Jenkinsfile' - changeset 'Makefile' - changeset 'Backend/**' - } - } - steps { - sh 'make push_backend' - } - } - } } diff --git a/Makefile b/Makefile index 24c7140..7ac133f 100644 --- a/Makefile +++ b/Makefile @@ -36,3 +36,7 @@ push_%: full_%: make build_$* make push_$* + +backend: login_registry + docker buildx build --platform linux/amd64,linux/arm64 -t git.letsstein.de/tom/arbeitszeit-backend:latest Backend --push + docker buildx build --platform linux/amd64,linux/arm64 -t git.letsstein.de/tom/arbeitszeit-backend:${GIT_COMMIT} Backend --push