diff --git a/login/Makefile b/login/Makefile index 6308f5234f..9fd43e727d 100644 --- a/login/Makefile +++ b/login/Makefile @@ -1,10 +1,11 @@ XDG_CACHE_HOME ?= $(HOME)/.cache export CACHE_DIR ?= $(XDG_CACHE_HOME)/zitadel-make -export LOGIN_DIR := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) - -export LOGIN_BAKE_CLI ?= docker buildx bake +LOGIN_DIR ?= ./ +LOGIN_BAKE_CLI ?= docker buildx bake LOGIN_BAKE_CLI_WITH_COMMON_ARGS := $(LOGIN_BAKE_CLI) --file $(LOGIN_DIR)docker-bake.hcl --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose.yaml +LOGIN_BAKE_CLI_ADDITIONAL_ARGS ?= +LOGIN_BAKE_CLI_WITH_COMMON_ARGS += $(LOGIN_BAKE_CLI_ADDITIONAL_ARGS) export COMPOSE_BAKE=true export UID := $(id -u) @@ -26,7 +27,7 @@ export LOGIN_TEST_ACCEPTANCE_SAMLIDP_TAG := login-test-acceptance-samlidp:${DOCK export POSTGRES_TAG := postgres:17.0-alpine3.19 export GOLANG_TAG := golang:1.24-alpine export ZITADEL_TAG ?= ghcr.io/zitadel/zitadel:v3.3.0 -export CORE_MOCK_TAG := core-mock:${DOCKER_METADATA_OUTPUT_VERSION} +export CORE_MOCK_TAG := login-core-mock:${DOCKER_METADATA_OUTPUT_VERSION} .PHONY: login-help login-help: @@ -49,10 +50,10 @@ login-test-unit: $(LOGIN_BAKE_CLI_WITH_COMMON_ARGS) login-test-unit login-test-integration-build: - $(LOGIN_BAKE_CLI_WITH_COMMON_ARGS) core-mock login-test-integration login-standalone + $(LOGIN_BAKE_CLI_WITH_COMMON_ARGS) login-core-mock login-test-integration login-standalone login-test-integration-dev: login-test-integration-cleanup - $(LOGIN_BAKE_CLI_WITH_COMMON_ARGS) core-mock && docker compose --file $(LOGIN_DIR)apps/login-test-integration/docker-compose.yaml run --service-ports --rm core-mock + $(LOGIN_BAKE_CLI_WITH_COMMON_ARGS) login-core-mock && docker compose --file $(LOGIN_DIR)apps/login-test-integration/docker-compose.yaml run --service-ports --rm login-core-mock login-test-integration-run: login-test-integration-cleanup docker compose --file $(LOGIN_DIR)apps/login-test-integration/docker-compose.yaml run --rm integration diff --git a/login/docker-bake.hcl b/login/docker-bake.hcl index 76eab2fac1..4553940d44 100644 --- a/login/docker-bake.hcl +++ b/login/docker-bake.hcl @@ -1,19 +1,40 @@ -variable "LOGIN_DIR" { - default = "./" -} - variable "DOCKERFILES_DIR" { default = "dockerfiles/" } +# typescript-proto-client is used to generate the client code for the login service. +# It is not login-prefixed, so it is easily extendable. +# To extend this bake-file.hcl, set the context of all login-prefixed targets to a different directory. +# For example docker bake --file login/docker-bake.hcl --file docker-bake.hcl --set login-*.context=./login/ +# The zitadel repository uses this to generate the client and the mock server from local proto files. +target "typescript-proto-client" { + dockerfile = "${DOCKERFILES_DIR}typescript-proto-client.Dockerfile" + contexts = { + # We directly generate and download the client server-side with buf, so we don't need the proto files + login-pnpm = "target:login-pnpm" + } + output = ["type=docker"] +} + +# proto-files is only used to build login-core-mock against which the integration tests run. +# To build the proto-client, we use buf to generate and download the client code directly. +# It is not login-prefixed, so it is easily extendable. +# To extend this bake-file.hcl, set the context of all login-prefixed targets to a different directory. +# For example docker bake --file login/docker-bake.hcl --file docker-bake.hcl --set login-*.context=./login/ +# The zitadel repository uses this to generate the client and the mock server from local proto files. +target "proto-files" { + dockerfile = "${DOCKERFILES_DIR}proto-files.Dockerfile" + contexts = { + login-pnpm = "target:login-pnpm" + } +} + target "login-pnpm" { - context = "${LOGIN_DIR}" dockerfile = "${DOCKERFILES_DIR}login-pnpm.Dockerfile" } target "login-dev-base" { dockerfile = "${DOCKERFILES_DIR}login-dev-base.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } @@ -21,7 +42,6 @@ target "login-dev-base" { target "login-lint" { dockerfile = "${DOCKERFILES_DIR}login-lint.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-dev-base = "target:login-dev-base" } @@ -29,7 +49,6 @@ target "login-lint" { target "login-test-unit" { dockerfile = "${DOCKERFILES_DIR}login-test-unit.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-client = "target:login-client" } @@ -37,7 +56,6 @@ target "login-test-unit" { target "login-client" { dockerfile = "${DOCKERFILES_DIR}login-client.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" typescript-proto-client = "target:typescript-proto-client" @@ -46,7 +64,6 @@ target "login-client" { target "typescript-proto-client" { dockerfile = "${DOCKERFILES_DIR}typescript-proto-client.Dockerfile" - context = "${LOGIN_DIR}" contexts = { # We directly generate and download the client server-side with buf, so we don't need the proto files login-pnpm = "target:login-pnpm" @@ -54,26 +71,16 @@ target "typescript-proto-client" { output = ["type=docker"] } -# proto-files is only used to build core-mock against which the integration tests run. -# To build the proto-client, we use buf to generate and download the client code directly. -target "proto-files" { - dockerfile = "${DOCKERFILES_DIR}proto-files.Dockerfile" - context = "${LOGIN_DIR}" - contexts = { - login-pnpm = "target:login-pnpm" - } +variable "LOGIN_CORE_MOCK_TAG" { + default = "login-core-mock:local" } -variable "CORE_MOCK_TAG" { - default = "core-mock:local" -} - -target "core-mock" { - context = "${LOGIN_DIR}apps/login-test-integration/core-mock" +target "login-core-mock" { + context = "/apps/login-test-integration/core-mock" contexts = { protos = "target:proto-files" } - tags = ["${CORE_MOCK_TAG}"] + tags = ["${LOGIN_CORE_MOCK_TAG}"] output = ["type=docker"] } @@ -83,7 +90,6 @@ variable "LOGIN_TEST_INTEGRATION_TAG" { target "login-test-integration" { dockerfile = "${DOCKERFILES_DIR}login-test-integration.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } @@ -97,7 +103,6 @@ variable "LOGIN_TEST_ACCEPTANCE_TAG" { target "login-test-acceptance" { dockerfile = "${DOCKERFILES_DIR}login-test-acceptance.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } @@ -115,7 +120,6 @@ target "docker-metadata-action" {} target "login-standalone" { inherits = ["docker-metadata-action"] dockerfile = "${DOCKERFILES_DIR}login-standalone.Dockerfile" - context = "${LOGIN_DIR}" contexts = { login-client = "target:login-client" }