From 6c16e081de85be811c94fb7a7aa8c1df21caa584 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 13 Jun 2025 10:19:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB(docker)=20cre?= =?UTF-8?q?ate=20a=20e2e=20compose=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to run the e2e tests using the frontend and y-provider production images. We created a dedicated compose file adding just missing services. These services are built in the CI. --- .github/workflows/impress-frontend.yml | 4 +-- Makefile | 48 +++++++++++++++++++++----- compose-e2e.yml | 28 +++++++++++++++ compose.yml | 4 +-- 4 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 compose-e2e.yml diff --git a/.github/workflows/impress-frontend.yml b/.github/workflows/impress-frontend.yml index 4dfd3298..b3eff3f9 100644 --- a/.github/workflows/impress-frontend.yml +++ b/.github/workflows/impress-frontend.yml @@ -86,7 +86,7 @@ jobs: run: cd src/frontend/apps/e2e && yarn install --frozen-lockfile && yarn install-playwright chromium - name: Start Docker services - run: make bootstrap FLUSH_ARGS='--no-input' cache= + run: make bootstrap-e2e FLUSH_ARGS='--no-input' cache= - name: Run e2e tests run: cd src/frontend/ && yarn e2e:test --project='chromium' @@ -125,7 +125,7 @@ jobs: run: cd src/frontend/apps/e2e && yarn install --frozen-lockfile && yarn install-playwright firefox webkit chromium - name: Start Docker services - run: make bootstrap FLUSH_ARGS='--no-input' cache= + run: make bootstrap-e2e FLUSH_ARGS='--no-input' cache= - name: Run e2e tests run: cd src/frontend/ && yarn e2e:test --project=firefox --project=webkit diff --git a/Makefile b/Makefile index d917b391..4c0b8c21 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,7 @@ DOCKER_UID = $(shell id -u) DOCKER_GID = $(shell id -g) DOCKER_USER = $(DOCKER_UID):$(DOCKER_GID) COMPOSE = DOCKER_USER=$(DOCKER_USER) docker compose +COMPOSE_E2E = DOCKER_USER=$(DOCKER_USER) docker compose -f compose.yml -f compose-e2e.yml COMPOSE_EXEC = $(COMPOSE) exec COMPOSE_EXEC_APP = $(COMPOSE_EXEC) app-dev COMPOSE_RUN = $(COMPOSE) run --rm @@ -74,11 +75,16 @@ create-env-files: \ env.d/development/kc_postgresql .PHONY: create-env-files -bootstrap: ## Prepare Docker images for the project -bootstrap: \ +base-bootstrap: +base-bootstrap: \ data/media \ data/static \ - create-env-files \ + create-env-files +.PHONY: base-bootstrap + +bootstrap: ## Prepare Docker images for the project +bootstrap: \ + base-bootstrap \ build \ migrate \ demo \ @@ -88,6 +94,18 @@ bootstrap: \ run .PHONY: bootstrap +bootstrap-e2e: ## Prepare Docker production images to be used for e2e tests +bootstrap-e2e: \ + base-bootstrap \ + build-e2e \ + migrate \ + demo \ + back-i18n-compile \ + mails-install \ + mails-build \ + run-e2e +.PHONY: bootstrap-e2e + # -- Docker/compose build: cache ?= --no-cache build: ## build the project containers @@ -103,7 +121,7 @@ build-backend: ## build the app-dev container build-yjs-provider: cache ?= build-yjs-provider: ## build the y-provider container - @$(COMPOSE) build y-provider $(cache) + @$(COMPOSE) build y-provider-development $(cache) .PHONY: build-yjs-provider build-frontend: cache ?= @@ -111,8 +129,14 @@ build-frontend: ## build the frontend container @$(COMPOSE) build frontend-development $(cache) .PHONY: build-frontend +build-e2e: ## build the e2e container + @$(MAKE) build-backend + @$(COMPOSE_E2E) build frontend + @$(COMPOSE_E2E) build y-provider +.PHONY: build-e2e + down: ## stop and remove containers, networks, images, and volumes - @$(COMPOSE) down + @$(COMPOSE_E2E) down .PHONY: down logs: ## display app-dev logs (follow mode) @@ -121,7 +145,7 @@ logs: ## display app-dev logs (follow mode) run-backend: ## Start only the backend application and all needed services @$(COMPOSE) up --force-recreate -d celery-dev - @$(COMPOSE) up --force-recreate -d y-provider + @$(COMPOSE) up --force-recreate -d y-provider-development @$(COMPOSE) up --force-recreate -d nginx .PHONY: run-backend @@ -131,12 +155,20 @@ run: @$(COMPOSE) up --force-recreate -d frontend-development .PHONY: run +run-e2e: ## start the e2e server +run-e2e: + @$(MAKE) run-backend + @$(COMPOSE_E2E) stop y-provider-development + @$(COMPOSE_E2E) up --force-recreate -d frontend + @$(COMPOSE_E2E) up --force-recreate -d y-provider +.PHONY: run-e2e + status: ## an alias for "docker compose ps" - @$(COMPOSE) ps + @$(COMPOSE_E2E) ps .PHONY: status stop: ## stop the development server using Docker - @$(COMPOSE) stop + @$(COMPOSE_E2E) stop .PHONY: stop # -- Backend diff --git a/compose-e2e.yml b/compose-e2e.yml new file mode 100644 index 00000000..5b05b4cf --- /dev/null +++ b/compose-e2e.yml @@ -0,0 +1,28 @@ +services: + + frontend: + user: "${DOCKER_USER:-1000}" + build: + context: . + dockerfile: ./src/frontend/Dockerfile + target: frontend-production + args: + API_ORIGIN: "http://localhost:8071" + PUBLISH_AS_MIT: "false" + SW_DEACTIVATED: "true" + image: impress:frontend-production + ports: + - "3000:3000" + + y-provider: + user: ${DOCKER_USER:-1000} + build: + context: . + dockerfile: ./src/frontend/servers/y-provider/Dockerfile + target: y-provider + image: impress:y-provider-production + restart: unless-stopped + env_file: + - env.d/development/common + ports: + - "4444:4444" \ No newline at end of file diff --git a/compose.yml b/compose.yml index 5f135876..adb69431 100644 --- a/compose.yml +++ b/compose.yml @@ -107,8 +107,6 @@ services: depends_on: app-dev: condition: service_started - y-provider: - condition: service_started keycloak: condition: service_healthy restart: true @@ -148,7 +146,7 @@ services: volumes: - ".:/app" - y-provider: + y-provider-development: user: ${DOCKER_USER:-1000} build: context: .