Stop rebuilding AI service on every deploy
This commit is contained in:
@@ -64,6 +64,7 @@ jobs:
|
|||||||
host: ${{ secrets.PROD_HOST }}
|
host: ${{ secrets.PROD_HOST }}
|
||||||
username: ${{ secrets.PROD_USER }}
|
username: ${{ secrets.PROD_USER }}
|
||||||
key: ${{ secrets.PROD_SSH_KEY }}
|
key: ${{ secrets.PROD_SSH_KEY }}
|
||||||
|
command_timeout: 40m
|
||||||
script: |
|
script: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ ! -d /opt/job-tracker/app/.git ]; then
|
if [ ! -d /opt/job-tracker/app/.git ]; then
|
||||||
|
|||||||
+25
-6
@@ -22,28 +22,47 @@ fi
|
|||||||
export APP_VERSION="${APP_VERSION:-0.0.0}"
|
export APP_VERSION="${APP_VERSION:-0.0.0}"
|
||||||
export APP_COMMIT_SHA="${APP_COMMIT_SHA:-unknown}"
|
export APP_COMMIT_SHA="${APP_COMMIT_SHA:-unknown}"
|
||||||
export APP_BUILD_STAMP="${APP_BUILD_STAMP:-unknown}"
|
export APP_BUILD_STAMP="${APP_BUILD_STAMP:-unknown}"
|
||||||
|
export DEPLOY_BUILD_AI_SERVICE="${DEPLOY_BUILD_AI_SERVICE:-false}"
|
||||||
|
|
||||||
compose() {
|
compose() {
|
||||||
docker compose "$@"
|
docker compose "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
build_with_recovery() {
|
build_core_with_recovery() {
|
||||||
if compose build; then
|
if compose build backend frontend; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "docker compose build failed. Attempting one cleanup + retry because layer extraction can fail on constrained hosts."
|
echo "docker compose build for core services failed. Attempting one cleanup + retry because layer extraction can fail on constrained hosts."
|
||||||
|
docker builder prune -af >/dev/null 2>&1 || true
|
||||||
|
docker system prune -f >/dev/null 2>&1 || true
|
||||||
|
compose build --no-cache backend frontend
|
||||||
|
}
|
||||||
|
|
||||||
|
build_ai_with_recovery() {
|
||||||
|
if compose build ai-service; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "docker compose build for ai-service failed. Attempting one cleanup + retry because layer extraction can fail on constrained hosts."
|
||||||
docker image rm -f app-ai-service:latest 2>/dev/null || true
|
docker image rm -f app-ai-service:latest 2>/dev/null || true
|
||||||
docker builder prune -af >/dev/null 2>&1 || true
|
docker builder prune -af >/dev/null 2>&1 || true
|
||||||
docker system prune -f >/dev/null 2>&1 || true
|
docker system prune -f >/dev/null 2>&1 || true
|
||||||
compose build --no-cache ai-service
|
compose build --no-cache ai-service
|
||||||
compose build backend frontend
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compose pull || true
|
compose pull || true
|
||||||
build_with_recovery
|
build_core_with_recovery
|
||||||
|
if [ "$DEPLOY_BUILD_AI_SERVICE" = "true" ]; then
|
||||||
|
build_ai_with_recovery
|
||||||
|
else
|
||||||
|
echo "Skipping ai-service rebuild during deploy (set DEPLOY_BUILD_AI_SERVICE=true to rebuild it)."
|
||||||
|
fi
|
||||||
# Force recreation so updated port mappings, env vars, and container config always apply on deploy.
|
# Force recreation so updated port mappings, env vars, and container config always apply on deploy.
|
||||||
compose up -d --force-recreate --remove-orphans
|
compose up -d --force-recreate --remove-orphans backend frontend
|
||||||
|
if [ "$DEPLOY_BUILD_AI_SERVICE" = "true" ]; then
|
||||||
|
compose up -d --force-recreate ai-service ollama
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${OLLAMA_MODEL:-}" ]; then
|
if [ -n "${OLLAMA_MODEL:-}" ]; then
|
||||||
echo "Post-deploy Ollama warmup enabled for model: ${OLLAMA_MODEL}"
|
echo "Post-deploy Ollama warmup enabled for model: ${OLLAMA_MODEL}"
|
||||||
|
|||||||
Reference in New Issue
Block a user