produzione 1 #9

Merged
JoeKung merged 135 commits from dev into main 2026-03-03 09:58:04 +01:00
3 changed files with 38 additions and 9 deletions
Showing only changes of commit 7bb94da45b - Show all commits

View File

@@ -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"

View File

@@ -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

View File

@@ -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: