Deploy call-center to production host
This commit is contained in:
+30
-5
@@ -212,17 +212,42 @@ deploy-production-source:
|
||||
DOCKER_TLS_VERIFY: ""
|
||||
DOCKER_CERT_PATH: ""
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DEPLOY_DIR: /home/gitlab-runner/deploy/call-center
|
||||
APP_IMAGE_NAME: call-center-app
|
||||
HEALTHCHECK_URL: http://127.0.0.1:8080/health
|
||||
environment:
|
||||
name: production
|
||||
before_script:
|
||||
- command -v rsync >/dev/null
|
||||
- command -v docker >/dev/null
|
||||
- command -v python3 >/dev/null
|
||||
- command -v ssh >/dev/null
|
||||
- command -v scp >/dev/null
|
||||
- command -v gzip >/dev/null
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- cp "$DEPLOY_SSH_PRIVATE_KEY" ~/.ssh/id_ed25519
|
||||
- chmod 600 ~/.ssh/id_ed25519
|
||||
- ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
script:
|
||||
- bash scripts/deploy_gitlab.sh
|
||||
- test -n "$DEPLOY_HOST"
|
||||
- test -n "$DEPLOY_USER"
|
||||
- test -n "$DEPLOY_COMPOSE_FILE"
|
||||
- IMAGE_ARCHIVE="call-center-app-${CI_COMMIT_SHORT_SHA}.tar.gz"
|
||||
- docker build -t "${APP_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" -t "${APP_IMAGE_NAME}:active-main" -t "${APP_IMAGE_NAME}:latest" -t "${APP_IMAGE_NAME}:ai-orchestrator" -t "${APP_IMAGE_NAME}:streaming-asr" -t "${APP_IMAGE_NAME}:asterisk-bridge" -t "${APP_IMAGE_NAME}:reporting-supervisor" .
|
||||
- docker save "${APP_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" "${APP_IMAGE_NAME}:active-main" "${APP_IMAGE_NAME}:latest" "${APP_IMAGE_NAME}:ai-orchestrator" "${APP_IMAGE_NAME}:streaming-asr" "${APP_IMAGE_NAME}:asterisk-bridge" "${APP_IMAGE_NAME}:reporting-supervisor" | gzip > "$IMAGE_ARCHIVE"
|
||||
- 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
|
||||
sudo docker compose -f '${DEPLOY_COMPOSE_FILE}' up -d --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'
|
||||
rm -f /tmp/call-center-ai-voice-runtime.env
|
||||
fi
|
||||
sudo docker image prune -f --filter dangling=true
|
||||
sudo docker ps --filter 'name=^call-center-app$' --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
|
||||
"
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||
- if: '$CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||
|
||||
Reference in New Issue
Block a user