From 1bb01f82de263c9f5ecec34004de5697d782b9bb Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 23 Jun 2025 15:23:52 +0200 Subject: [PATCH] pin login dir --- Makefile | 22 ++++++++++--------- docker-bake.hcl | 56 ++++++++++++++++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 0dff26c3eb..c65de742d3 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,16 @@ XDG_CACHE_HOME ?= $(HOME)/.cache export CACHE_DIR ?= $(XDG_CACHE_HOME)/zitadel-make +export LOGIN_DIR := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) + export BAKE_CLI ?= docker buildx bake -BAKE_CLI_WITH_COMMON_ARGS := $(BAKE_CLI) --file ./docker-bake.hcl --file ./apps/login-test-acceptance/docker-compose.yaml +BAKE_CLI_WITH_COMMON_ARGS := $(BAKE_CLI) --file $(LOGIN_DIR)docker-bake.hcl --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose.yaml export COMPOSE_BAKE=true export UID := $(id -u) export GID := $(id -g) -export LOGIN_TEST_ACCEPTANCE_BUILD_CONTEXT := apps/login-test-acceptance +export LOGIN_TEST_ACCEPTANCE_BUILD_CONTEXT := $(LOGIN_DIR)apps/login-test-acceptance export DOCKER_METADATA_OUTPUT_VERSION ?= local export LOGIN_TAG := login:${DOCKER_METADATA_OUTPUT_VERSION} @@ -50,17 +52,17 @@ login-test-integration-build: $(BAKE_CLI_WITH_COMMON_ARGS) core-mock login-test-integration login-standalone login-test-integration-dev: login-test-integration-cleanup - $(BAKE_CLI_WITH_COMMON_ARGS) core-mock && docker compose --file ./apps/login-test-integration/docker-compose.yaml run --service-ports --rm core-mock + $(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-test-integration-run: login-test-integration-cleanup - docker compose --file ./apps/login-test-integration/docker-compose.yaml run --rm integration + docker compose --file $(LOGIN_DIR)apps/login-test-integration/docker-compose.yaml run --rm integration login-test-integration-cleanup: - docker compose --file ./apps/login-test-integration/docker-compose.yaml down --volumes + docker compose --file $(LOGIN_DIR)apps/login-test-integration/docker-compose.yaml down --volumes .PHONY: login-test-integration login-test-integration: login-test-integration-build - ./scripts/run_or_skip.sh login-test-integration-run \ + $(LOGIN_DIR)scripts/run_or_skip.sh login-test-integration-run \ "$(LOGIN_TAG) \ $(CORE_MOCK_TAG) \ $(LOGIN_TEST_INTEGRATION_TAG)" @@ -75,16 +77,16 @@ login-test-acceptance-build: login-test-acceptance-build-compose login-test-acce @: login-test-acceptance-dev: login-test-acceptance-build-compose login-test-acceptance-cleanup - docker compose --file ./apps/login-test-acceptance/docker-compose.yaml up zitadel setup traefik setup sink + docker compose --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose.yaml up zitadel setup traefik setup sink login-test-acceptance-run: login-test-acceptance-cleanup - docker compose --file ./apps/login-test-acceptance/docker-compose.yaml --file ./apps/login-test-acceptance/docker-compose-ci.yaml run --rm --service-ports acceptance + docker compose --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose.yaml --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose-ci.yaml run --rm --service-ports acceptance login-test-acceptance-cleanup: - docker compose --file ./apps/login-test-acceptance/docker-compose.yaml --file ./apps/login-test-acceptance/docker-compose-ci.yaml down --volumes + docker compose --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose.yaml --file $(LOGIN_DIR)apps/login-test-acceptance/docker-compose-ci.yaml down --volumes login-test-acceptance: login-test-acceptance-build - ./scripts/run_or_skip.sh login-test-acceptance-run \ + $(LOGIN_DIR)scripts/run_or_skip.sh login-test-acceptance-run \ "$(LOGIN_TAG) \ $(ZITADEL_TAG) \ $(POSTGRES_TAG) \ diff --git a/docker-bake.hcl b/docker-bake.hcl index 7489b86efb..76eab2fac1 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,30 +1,43 @@ +variable "LOGIN_DIR" { + default = "./" +} + +variable "DOCKERFILES_DIR" { + default = "dockerfiles/" +} + target "login-pnpm" { - dockerfile = "dockerfiles/login-pnpm.Dockerfile" - } + context = "${LOGIN_DIR}" + dockerfile = "${DOCKERFILES_DIR}login-pnpm.Dockerfile" +} target "login-dev-base" { - dockerfile = "dockerfiles/login-dev-base.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}login-dev-base.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } } target "login-lint" { - dockerfile = "dockerfiles/login-lint.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}login-lint.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-dev-base = "target:login-dev-base" } } target "login-test-unit" { - dockerfile = "dockerfiles/login-test-unit.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}login-test-unit.Dockerfile" + context = "${LOGIN_DIR}" contexts = { - login-client = "target:login-client" + login-client = "target:login-client" } } target "login-client" { - dockerfile = "dockerfiles/login-client.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}login-client.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" typescript-proto-client = "target:typescript-proto-client" @@ -32,18 +45,20 @@ target "login-client" { } target "typescript-proto-client" { - dockerfile = "dockerfiles/typescript-proto-client.Dockerfile" + 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" } - output = ["type=docker"] + 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/proto-files.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}proto-files.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } @@ -54,11 +69,11 @@ variable "CORE_MOCK_TAG" { } target "core-mock" { - context = "apps/login-test-integration/core-mock" + context = "${LOGIN_DIR}apps/login-test-integration/core-mock" contexts = { protos = "target:proto-files" } - tags = ["${CORE_MOCK_TAG}"] + tags = ["${CORE_MOCK_TAG}"] output = ["type=docker"] } @@ -67,11 +82,12 @@ variable "LOGIN_TEST_INTEGRATION_TAG" { } target "login-test-integration" { - dockerfile = "dockerfiles/login-test-integration.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}login-test-integration.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } - tags = ["${LOGIN_TEST_INTEGRATION_TAG}"] + tags = ["${LOGIN_TEST_INTEGRATION_TAG}"] output = ["type=docker"] } @@ -80,11 +96,12 @@ variable "LOGIN_TEST_ACCEPTANCE_TAG" { } target "login-test-acceptance" { - dockerfile = "dockerfiles/login-test-acceptance.Dockerfile" + dockerfile = "${DOCKERFILES_DIR}login-test-acceptance.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-pnpm = "target:login-pnpm" } - tags = ["${LOGIN_TEST_ACCEPTANCE_TAG}"] + tags = ["${LOGIN_TEST_ACCEPTANCE_TAG}"] output = ["type=docker"] } @@ -96,11 +113,12 @@ target "docker-metadata-action" {} # We run integration and acceptance tests against the next standalone server for docker. target "login-standalone" { - inherits = ["docker-metadata-action"] - dockerfile = "dockerfiles/login-standalone.Dockerfile" + inherits = ["docker-metadata-action"] + dockerfile = "${DOCKERFILES_DIR}login-standalone.Dockerfile" + context = "${LOGIN_DIR}" contexts = { login-client = "target:login-client" } - tags = ["${LOGIN_TAG}"] + tags = ["${LOGIN_TAG}"] output = ["type=docker"] }