From 7bb94da45b5872853df106110f400841bb527b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20K=C3=BCng?= Date: Wed, 18 Feb 2026 21:48:09 +0100 Subject: [PATCH] fix(back-end): try fix profile manager --- .gitea/workflows/cicd.yaml | 9 +++++++-- backend/entrypoint.sh | 22 +++++++++++++++++----- docker-compose.deploy.yml | 16 ++++++++++++++-- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/cicd.yaml b/.gitea/workflows/cicd.yaml index d5d5f80..b422270 100644 --- a/.gitea/workflows/cicd.yaml +++ b/.gitea/workflows/cicd.yaml @@ -125,7 +125,7 @@ jobs: ssh-keyscan -H "${{ secrets.SERVER_HOST }}" >> ~/.ssh/known_hosts 2>/dev/null - - name: Write env to server + - name: Write env and compose to server shell: bash run: | # 1. Start with the static env file content @@ -154,9 +154,14 @@ jobs: echo "Preparing to send env file with variables:" grep -v "PASSWORD" /tmp/full_env.env || true - # 5. Send to server + # 5. Send env to server ssh -i ~/.ssh/id_ed25519 -o BatchMode=yes "${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}" \ "setenv ${{ env.ENV }}" < /tmp/full_env.env + + # 6. Send docker-compose.deploy.yml to server + # We use a trick to find the base_dir: we look where the script usually puts things + cat docker-compose.deploy.yml | ssh -i ~/.ssh/id_ed25519 -o BatchMode=yes "${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}" \ + "cat > /mnt/cache/appdata/print-calculator/docker-compose-deploy.yml 2>/dev/null || cat > /mnt/user/appdata/print-calculator/docker-compose-deploy.yml" diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index 1dcaaa2..8013e19 100644 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -3,13 +3,25 @@ echo "----------------------------------------------------------------" echo "Starting Backend Application" echo "DB_URL: $DB_URL" echo "DB_USERNAME: $DB_USERNAME" +echo "SPRING_DATASOURCE_URL: $SPRING_DATASOURCE_URL" echo "SLICER_PATH: $SLICER_PATH" echo "--- ALL ENV VARS ---" env echo "----------------------------------------------------------------" -# Exec java with explicit properties from env -exec java -jar app.jar \ - --spring.datasource.url="${DB_URL}" \ - --spring.datasource.username="${DB_USERNAME}" \ - --spring.datasource.password="${DB_PASSWORD}" +# Determine which environment variables to use for database connection +# This allows compatibility with different docker-compose configurations +FINAL_DB_URL="${DB_URL:-$SPRING_DATASOURCE_URL}" +FINAL_DB_USER="${DB_USERNAME:-$SPRING_DATASOURCE_USERNAME}" +FINAL_DB_PASS="${DB_PASSWORD:-$SPRING_DATASOURCE_PASSWORD}" + +if [ -n "$FINAL_DB_URL" ]; then + echo "Using database URL: $FINAL_DB_URL" + exec java -jar app.jar \ + --spring.datasource.url="${FINAL_DB_URL}" \ + --spring.datasource.username="${FINAL_DB_USER}" \ + --spring.datasource.password="${FINAL_DB_PASS}" +else + echo "No database URL specified in environment, relying on application.properties defaults." + exec java -jar app.jar +fi diff --git a/docker-compose.deploy.yml b/docker-compose.deploy.yml index 777bdc4..435e8ea 100644 --- a/docker-compose.deploy.yml +++ b/docker-compose.deploy.yml @@ -8,18 +8,25 @@ services: ports: - "${BACKEND_PORT}:8000" environment: + - SPRING_PROFILES_ACTIVE=${ENV} - DB_URL=${DB_URL} - DB_USERNAME=${DB_USERNAME} - DB_PASSWORD=${DB_PASSWORD} - TEMP_DIR=/app/temp - PROFILES_DIR=/app/profiles restart: always - volumes: + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + volumes: - backend_profiles_${ENV}:/app/profiles - /mnt/cache/appdata/print-calculator/${ENV}/storage_quotes:/app/storage_quotes - /mnt/cache/appdata/print-calculator/${ENV}/storage_orders:/app/storage_orders - /mnt/cache/appdata/print-calculator/${ENV}/storage_requests:/app/storage_requests - + extra_hosts: + - "host.docker.internal:host-gateway" frontend: image: ${REGISTRY_URL}/${REPO_OWNER}/print-calculator-frontend:${TAG} @@ -29,6 +36,11 @@ services: depends_on: - backend restart: always + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" volumes: backend_profiles_prod: