From 3e15158126f4d265ea0269adc6b573ab23bf7339 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 11 May 2026 09:52:00 +0000 Subject: [PATCH] Resolve source deploy root for env file --- .gitlab-ci.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 75f20ff..a7aac71 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -238,21 +238,38 @@ deploy-production-source: if [ "$DEPLOY_COMPOSE_DIR" = "$DEPLOY_COMPOSE_FILE" ]; then DEPLOY_COMPOSE_DIR="." fi - DEPLOY_SOURCE_COMPOSE_FILE="$DEPLOY_COMPOSE_DIR/docker-compose.server.yml" - ssh "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_COMPOSE_DIR'" - scp -r deployment/. "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_COMPOSE_DIR/" + DEPLOY_SOURCE_ROOT="${DEPLOY_PATH:-}" + if [ -z "$DEPLOY_SOURCE_ROOT" ]; then + DEPLOY_SOURCE_ROOT="$(ssh "${DEPLOY_USER}@${DEPLOY_HOST}" " + set -e + compose_dir='$DEPLOY_COMPOSE_DIR' + parent_dir=\$(dirname \"\$compose_dir\") + if [ -f \"\$parent_dir/call-center/.env.production\" ]; then + printf '%s' \"\$parent_dir/call-center\" + elif [ -f \"\$parent_dir/.env.production\" ]; then + printf '%s' \"\$parent_dir\" + else + printf '%s' \"\$parent_dir\" + fi + ")" + fi + DEPLOY_SOURCE_COMPOSE_DIR="$DEPLOY_SOURCE_ROOT/deployment" + DEPLOY_SOURCE_COMPOSE_FILE="$DEPLOY_SOURCE_COMPOSE_DIR/docker-compose.server.yml" + ssh "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p '$DEPLOY_SOURCE_COMPOSE_DIR'" + scp -r deployment/. "${DEPLOY_USER}@${DEPLOY_HOST}:$DEPLOY_SOURCE_COMPOSE_DIR/" - scp "$IMAGE_ARCHIVE" "${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/$IMAGE_ARCHIVE" - | ssh "${DEPLOY_USER}@${DEPLOY_HOST}" " set -e gunzip -c /tmp/$IMAGE_ARCHIVE | sudo docker load rm -f /tmp/$IMAGE_ARCHIVE + test -f '$DEPLOY_SOURCE_ROOT/.env.production' sudo env CALL_CENTER_IMAGE='${APP_IMAGE_NAME}:active-main' APP_IMAGE='${APP_IMAGE_NAME}:active-main' docker compose -f '$DEPLOY_SOURCE_COMPOSE_FILE' config -q sudo env CALL_CENTER_IMAGE='${APP_IMAGE_NAME}:active-main' APP_IMAGE='${APP_IMAGE_NAME}:active-main' docker compose -f '$DEPLOY_SOURCE_COMPOSE_FILE' up -d --no-build --remove-orphans --force-recreate if sudo docker ps -a --format '{{.Names}}' | grep -Fxq 'call-center-ai-voice-runtime-service-1'; then sudo docker inspect --format '{{range .Config.Env}}{{println .}}{{end}}' call-center-ai-voice-runtime-service-1 > /tmp/call-center-ai-voice-runtime.env sudo docker rm -f call-center-ai-voice-runtime-service-1 - sudo docker run -d --name call-center-ai-voice-runtime-service-1 --restart unless-stopped --network call-center_default --network-alias ai-voice-runtime-service -v /opt/konturai-migration/call-center/.data_local:/app/.data_local --add-host host.docker.internal:host-gateway --env-file /tmp/call-center-ai-voice-runtime.env call-center-app:active-main sh -c 'uvicorn \${APP_MODULE} --host 0.0.0.0 --port 8000' + sudo docker run -d --name call-center-ai-voice-runtime-service-1 --restart unless-stopped --network call-center_default --network-alias ai-voice-runtime-service -v '$DEPLOY_SOURCE_ROOT/.data_local:/app/.data_local' --add-host host.docker.internal:host-gateway --env-file /tmp/call-center-ai-voice-runtime.env call-center-app:active-main sh -c 'uvicorn \${APP_MODULE} --host 0.0.0.0 --port 8000' rm -f /tmp/call-center-ai-voice-runtime.env fi sudo docker image prune -f --filter dangling=true