This commit is contained in:
Florian Forster 2025-02-18 22:43:02 +01:00
parent 8101516442
commit a203b85a59
5 changed files with 76 additions and 53 deletions

1
.gitignore vendored
View File

@ -45,6 +45,7 @@ cmd/zitadel/zitadel
**/statik/statik.go **/statik/statik.go
/zitadelctl /zitadelctl
/zitadel /zitadel
.build
# buildfolders and generated files # buildfolders and generated files
tmp/ tmp/

View File

@ -1,32 +1,39 @@
ARG NODE_VERSION=22 ARG NODE_VERSION=22
ARG GO_VERSION=1.23 ARG GO_VERSION=1.23
## Console Base ## Console
FROM node:${NODE_VERSION} AS console-base FROM node:${NODE_VERSION} AS console-base
WORKDIR /app WORKDIR /app
COPY console/package.json console/yarn.lock console/buf.gen.yaml ./ COPY console/package.json console/yarn.lock console/buf.gen.yaml ./
COPY proto/ ../proto/ COPY proto/ ../proto/
RUN yarn install && yarn generate RUN yarn install && yarn generate
## Console Build
FROM console-base AS console-build
COPY console/ . COPY console/ .
COPY docs/frameworks.json ../docs/frameworks.json COPY docs/frameworks.json ../docs/frameworks.json
FROM console-base AS console-build
RUN yarn build RUN yarn build
## Console Image FROM console-base AS console-lint
FROM nginx:stable-alpine AS console RUN yarn lint
FROM nginx:stable-alpine AS console-image
RUN rm -rf /usr/share/nginx/html/* RUN rm -rf /usr/share/nginx/html/*
COPY .build/console/nginx.conf /etc/nginx/nginx.conf COPY .build/console/nginx.conf /etc/nginx/nginx.conf
COPY --from=console-build /app/dist /usr/share/nginx/html COPY --from=console-build /app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]
## Core Base FROM scratch AS console-output
COPY --from=console-build /app/dist/console .
## Core
FROM golang:${GO_VERSION} AS core-base FROM golang:${GO_VERSION} AS core-base
ARG SASS_VERSION=1.64.1 ARG SASS_VERSION=1.64.1
ARG GOLANG_CI_VERSION=1.64.5
RUN apt-get update && apt-get install -y npm && npm install -g sass@${SASS_VERSION} RUN apt-get update && apt-get install -y npm && npm install -g sass@${SASS_VERSION}
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANG_CI_VERSION}
WORKDIR /app WORKDIR /app
COPY go.mod go.sum Makefile buf.gen.yaml buf.work.yaml main.go ./ COPY go.mod go.sum Makefile buf.gen.yaml buf.work.yaml main.go .golangci.yaml ./
COPY .git/ .git/
COPY cmd/ cmd/ COPY cmd/ cmd/
COPY internal/ internal/ COPY internal/ internal/
COPY openapi/ openapi/ COPY openapi/ openapi/
@ -34,9 +41,18 @@ COPY pkg/ pkg/
COPY proto/ proto/ COPY proto/ proto/
COPY statik/ statik/ COPY statik/ statik/
COPY --from=console-build /app/dist/console internal/api/ui/console/static COPY --from=console-build /app/dist/console internal/api/ui/console/static
RUN ls -la proto/zitadel
RUN make core_build RUN make core_build
## Core Unit Test FROM core-base AS core-build
RUN make compile
FROM core-base AS core-lint
RUN make core_lint
FROM scratch AS core-output
COPY --from=core-build /app/zitadel .
FROM core-base AS core-image
FROM core-base AS core-unit-test FROM core-base AS core-unit-test
RUN make core_unit_test RUN make core_unit_test

View File

@ -14,14 +14,14 @@ ZITADEL_MASTERKEY ?= MasterkeyNeedsToHave32Characters
export GOCOVERDIR INTEGRATION_DB_FLAVOR ZITADEL_MASTERKEY export GOCOVERDIR INTEGRATION_DB_FLAVOR ZITADEL_MASTERKEY
.PHONY: compile .PHONY: compile
compile: core_build console_build compile_pipeline compile: core_build compile_pipeline
.PHONY: docker_image .PHONY: docker_image
docker_image: compile docker_image: compile
DOCKER_BUILDKIT=1 docker build -f build/Dockerfile -t $(ZITADEL_IMAGE) . DOCKER_BUILDKIT=1 docker build -f build/Dockerfile -t $(ZITADEL_IMAGE) .
.PHONY: compile_pipeline .PHONY: compile_pipeline
compile_pipeline: console_move compile_pipeline:
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)' " 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 chmod +x zitadel
@ -81,25 +81,6 @@ core_api: core_api_generator core_grpc_dependencies
.PHONY: core_build .PHONY: core_build
core_build: core_dependencies core_api core_static core_assets core_build: core_dependencies core_api core_static core_assets
.PHONY: console_move
console_move:
cp -r console/dist/console/* internal/api/ui/console/static
.PHONY: console_dependencies
console_dependencies:
cd console && \
yarn install --immutable
.PHONY: console_client
console_client:
cd console && \
yarn generate
.PHONY: console_build
console_build: console_dependencies console_client
cd console && \
yarn build
.PHONY: clean .PHONY: clean
clean: clean:
$(RM) -r .artifacts/grpc $(RM) -r .artifacts/grpc
@ -154,11 +135,6 @@ core_integration_reports:
.PHONY: core_integration_test .PHONY: core_integration_test
core_integration_test: core_integration_server_start core_integration_test_packages core_integration_server_stop core_integration_reports core_integration_test: core_integration_server_start core_integration_test_packages core_integration_server_stop core_integration_reports
.PHONY: console_lint
console_lint:
cd console && \
yarn lint
.PHONY: core_lint .PHONY: core_lint
core_lint: core_lint:
golangci-lint run \ golangci-lint run \

View File

@ -5,7 +5,6 @@
"ng": "ng", "ng": "ng",
"start": "node prebuild.development.js && ng serve", "start": "node prebuild.development.js && ng serve",
"build": "ng build --configuration production --base-href=/ui/console/", "build": "ng build --configuration production --base-href=/ui/console/",
"prelint": "npm run generate",
"lint": "ng lint && prettier --check src", "lint": "ng lint && prettier --check src",
"lint:fix": "prettier --write src", "lint:fix": "prettier --write src",
"generate": "buf generate ../proto --include-imports --include-wkt" "generate": "buf generate ../proto --include-imports --include-wkt"

View File

@ -3,46 +3,77 @@ variable "GITHUB_SHA" {
} }
variable "REGISTRY" { variable "REGISTRY" {
default = "ghcr.io/zitadel" default = "ghcr.io/fforootd"
} }
group "generate" { group "generate" {
targets = ["console-base"] targets = ["console-base", "core-base"]
}
group "build" {
targets = ["console-build", "core-build"]
}
group "output" {
targets = ["console-output", "core-output"]
} }
group "unit-test" { group "unit-test" {
targets = ["core-unit-test"] targets = ["core-unit-test"]
} }
group "lint" {
targets = ["console-lint", "core-lint"]
}
target "console-base" { target "console-base" {
target = "console-base" target = "console-base"
cache-from = ["type=gha,scope=console-base"]
cache-to = ["type=gha,mode=max,scope=console-base"]
} }
target "console-builder" { target "console-build" {
target = "console-builder" target = "console-build"
cache-from = ["type=gha,scope=console-builder"]
cache-to = ["type=gha,mode=max,scope=console-builder"]
} }
target "console" { target "console-lint" {
target = "console" target = "console-lint"
}
target "console-image" {
target = "console-image"
tags = [ tags = [
"${REGISTRY}/console:${GITHUB_SHA}", "${REGISTRY}/console:${GITHUB_SHA}",
] ]
cache-from = ["type=gha,scope=console"] }
cache-to = ["type=gha,mode=max,scope=console"]
target "console-output" {
target = "console-output"
output = ["type=local,dest=.build/console"]
} }
target "core-base" { target "core-base" {
target = "core-base" target = "core-base"
cache-from = ["type=gha,scope=core-base"] }
cache-to = ["type=gha,mode=max,scope=core-base"]
target "core-build" {
target = "core-build"
}
target "core-lint" {
target = "core-lint"
}
target "core-image" {
target = "core-image"
tags = [
"${REGISTRY}/zitadel:${GITHUB_SHA}",
]
}
target "core-output" {
target = "core-output"
output = ["type=local,dest=.build/core"]
} }
target "core-unit-test" { target "core-unit-test" {
target = "core-unit-test" target = "core-unit-test"
cache-from = ["type=gha,scope=core-unit-test"]
cache-to = ["type=gha,mode=max,scope=core-unit-test"]
} }