From 4050c08859c551c7ef1631c0c6c40a32056eeeab Mon Sep 17 00:00:00 2001 From: almazlar Date: Sun, 22 Feb 2026 12:29:53 +0300 Subject: [PATCH] fix: update API base URL and add healthcheck for backend service --- .gitea/workflows/docker-build.yml | 2 +- docker-compose.yml | 7 ++++++- frontend/Dockerfile | 4 ++++ frontend/src/services/api.js | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 09592fe..c7614eb 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -146,4 +146,4 @@ jobs: labels: ${{ steps.meta-frontend.outputs.labels }} build-args: | VITE_APP_VERSION=${{ steps.generate.outputs.new_tag }} - VITE_BASE_URL=https://todo.almazlar.com/api/todos + VITE_BASE_URL=https://todo.almazlar.com/api diff --git a/docker-compose.yml b/docker-compose.yml index 1d1fd69..fbaf48c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,12 +30,17 @@ services: depends_on: db: condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/actuator/health || exit 1"] + interval: 10s + timeout: 5s + retries: 5 frontend: build: context: ./frontend args: - VITE_BASE_URL: "http://localhost:8082/api/todos" + VITE_BASE_URL: "http://localhost:8082/api" container_name: todo-frontend ports: - "5173:80" diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 56c96be..4ed2feb 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -6,6 +6,10 @@ RUN npm install COPY . . ARG VITE_APP_VERSION=dev ENV VITE_APP_VERSION=${VITE_APP_VERSION} + +ARG VITE_BASE_URL=https://todo.almazlar.com/api +ENV VITE_BASE_URL=${VITE_BASE_URL} + RUN npm run build # Run stage diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js index 57314ce..9b1afac 100644 --- a/frontend/src/services/api.js +++ b/frontend/src/services/api.js @@ -2,7 +2,7 @@ // Vite automatically injects the variable defined in .env.* based on the current mode. // `import.meta.env.VITE_BASE_URL` is the single source of truth for the API root. -const BASE_URL = import.meta.env.VITE_BASE_URL; +const BASE_URL = import.meta.env.VITE_BASE_URL + '/todos'; // ----------------------------------------------------------------------------- // API helpers