diff --git a/Dockerfile.console b/Dockerfile.console index 60f77695e9..06fa385432 100644 --- a/Dockerfile.console +++ b/Dockerfile.console @@ -9,8 +9,10 @@ COPY docs/frameworks.json ../docs/frameworks.json FROM scratch AS generate COPY --from=base /app/src/app/proto/generated/ /console/src/app/proto/generated/ -FROM base AS build +FROM base AS builder RUN yarn build +FROM scratch AS build +COPY --from=builder /app/dist/console . FROM base AS lint RUN yarn lint @@ -20,6 +22,3 @@ RUN rm -rf /usr/share/nginx/html/* COPY nginx.conf /etc/nginx/nginx.conf COPY --from=build /app/dist /usr/share/nginx/html CMD ["nginx", "-g", "daemon off;"] - -FROM scratch AS output -COPY --from=build /app/dist/console . diff --git a/Dockerfile.core b/Dockerfile.core index 4ad6bfd5f3..acb3cce228 100644 --- a/Dockerfile.core +++ b/Dockerfile.core @@ -26,12 +26,37 @@ COPY --from=base /app/pkg/grpc/ /pkg/grpc/ COPY --from=base /app/openapi/ /openapi/ COPY --from=base /app/internal/api/assets/generator/ /internal/api/assets/generator/ -FROM base AS build +FROM base AS build-linux-amd64 COPY --from=console ./ internal/api/ui/console/static -COPY .goreleaser.yaml ./ -RUN goreleaser release --snapshot --clean -# RUN CGO_ENABLED=0 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ -# && chmod +x zitadel +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ + && chmod +x zitadel +FROM base AS build-linux-arm64 +COPY --from=console ./ internal/api/ui/console/static +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ + && chmod +x zitadel +FROM base AS build-darwin-amd64 +COPY --from=console ./ internal/api/ui/console/static +RUN CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ + && chmod +x zitadel +FROM base AS build-darwin-arm64 +COPY --from=console ./ internal/api/ui/console/static +RUN CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ + && chmod +x zitadel +FROM base AS build-windows-amd64 +COPY --from=console ./ internal/api/ui/console/static +RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ + && chmod +x zitadel +FROM base AS build-windows-arm64 +COPY --from=console ./ internal/api/ui/console/static +RUN CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit=${COMMIT_SHA}' -X 'github.com/zitadel/zitadel/cmd/build.date=${now}' -X 'github.com/zitadel/zitadel/cmd/build.version=${VERSION}' " \ + && chmod +x zitadel +FROM scratch AS build +COPY --from=build-linux-amd64 /app/zitadel zitadel-linux-amd64 +COPY --from=build-linux-arm64 /app/zitadel zitadel-linux-arm64 +COPY --from=build-darwin-amd64 /app/zitadel zitadel-darwin-amd64 +COPY --from=build-darwin-arm64 /app/zitadel zitadel-darwin-arm64 +COPY --from=build-windows-amd64 /app/zitadel zitadel-windows-amd64 +COPY --from=build-windows-arm64 /app/zitadel zitadel-windows-arm64 FROM base AS lint COPY --from=console ./ internal/api/ui/console/static @@ -39,13 +64,13 @@ COPY .golangci.yaml ./ COPY .git/ ./.git/ RUN make core_lint -FROM scratch AS output -COPY --from=build /app/zitadel . - -FROM base AS unit +FROM base AS unit-test COPY --from=console ./ internal/api/ui/console/static RUN go test -race -coverprofile=profile.cov -coverpkg=./internal/... ./... +FROM scratch AS unit +COPY --from=unit-test /app/profile.cov . + FROM debian:latest AS base-image ENV ZITADEL_ARGS= ARG TARGETPLATFORM @@ -69,4 +94,4 @@ COPY --from=base-image /etc/ssl/certs /etc/ssl/certs COPY --from=base-image /app/zitadel /app/zitadel HEALTHCHECK NONE USER zitadel -ENTRYPOINT ["/app/zitadel"] \ No newline at end of file +ENTRYPOINT ["/app/zitadel"] diff --git a/docker-bake.hcl b/docker-bake.hcl index 06b08c4924..910d7f8bb7 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -7,7 +7,7 @@ variable "REGISTRY" { } group "all" { - targets = ["build", "output", "lint", "image", "unit"] + targets = ["build", "lint", "image", "unit"] } group "build" { @@ -18,10 +18,6 @@ group "generate" { targets = ["console-generate" , "core-generate"] } -group "output" { - targets = ["console-output", "core-output"] -} - group "lint" { targets = ["console-lint", "core-lint"] } @@ -47,32 +43,28 @@ target "console" { name = "console-${tgt}" inherits = ["_console"] matrix = { - tgt = ["build", "output", "lint", "image", "generate"] + tgt = ["build", "lint", "image", "generate"] } output = { - "build" = ["type=cacheonly"] - "output" = ["type=local,dest=.build/console"] + "build" = ["type=local,dest=.build/console"] "lint" = ["type=cacheonly"] "image" = ["type=docker"] "generate" = ["type=local,dest=./"] }[tgt] tags = { "build" = [] - "output" = [] "lint" = [] "image" = ["${REGISTRY}/console:${GITHUB_SHA}"] "generate" = [] }[tgt] cache-to = { "build" = ["type=gha,ignore-error=true,mode=max,scope=console-${tgt}"] - "output" = ["type=gha,ignore-error=true,mode=max,scope=console-${tgt}"] "lint" = ["type=gha,ignore-error=true,mode=max,scope=console-${tgt}"] "image" = ["type=gha,ignore-error=true,mode=max,scope=console-${tgt}"] "generate" = ["type=gha,ignore-error=true,mode=max,scope=console-${tgt}"] }[tgt] cache-from = { "build" = ["type=gha,scope=console-${tgt}"] - "output" = ["type=gha,scope=console-${tgt}"] "lint" = ["type=gha,scope=console-${tgt}"] "image" = ["type=gha,scope=console-${tgt}"] "generate" = ["type=gha,scope=console-${tgt}"] @@ -98,19 +90,17 @@ target "core" { name = "core-${tgt}" inherits = ["_core"] matrix = { - tgt = ["build", "output", "lint", "image", "generate", "unit"] + tgt = ["build", "lint", "image", "generate", "unit"] } output = { - "build" = ["type=cacheonly"] - "output" = ["type=local,dest=.build/core"] + "build" = ["type=local,dest=.build/core"] "lint" = ["type=cacheonly"] - "unit" = ["type=cacheonly"] + "unit" = ["type=local,dest=./.build/core"] "image" = ["type=docker"] "generate" = ["type=local,dest=./"] }[tgt] tags = { "build" = [] - "output" = [] "lint" = [] "unit" = [] "image" = ["${REGISTRY}/zitadel:${GITHUB_SHA}"] @@ -118,7 +108,6 @@ target "core" { }[tgt] cache-to = { "build" = ["type=gha,ignore-error=true,mode=max,scope=core-${tgt}"] - "output" = ["type=gha,ignore-error=true,mode=max,scope=core-${tgt}"] "lint" = ["type=gha,ignore-error=true,mode=max,scope=core-${tgt}"] "unit" = ["type=gha,ignore-error=true,mode=max,scope=core-${tgt}"] "image" = ["type=gha,ignore-error=true,mode=max,scope=core-${tgt}"] @@ -126,7 +115,6 @@ target "core" { }[tgt] cache-from = { "build" = ["type=gha,scope=core-${tgt}"] - "output" = ["type=gha,scope=core-${tgt}"] "lint" = ["type=gha,scope=core-${tgt}"] "unit" = ["type=gha,scope=core-${tgt}"] "image" = ["type=gha,scope=core-${tgt}"]