intra_monitor/deploy/remote-deploy.sh
2026-03-18 14:19:29 +03:00

36 lines
787 B
Bash

#!/usr/bin/env sh
set -eu
APP_DIR=${APP_DIR:-/opt/intradesk-monitor}
COMPOSE_FILE=${COMPOSE_FILE:-docker-compose.deploy.yml}
cd "$APP_DIR"
mkdir -p data deploy
if [ ! -f .env ]; then
echo ".env is missing in $APP_DIR. Create it from .env.example before the first deploy." >&2
exit 1
fi
if [ -n "${IMAGE_REPO:-}" ] && [ -n "${IMAGE_TAG:-}" ]; then
cat > .env.runtime <<EOF
IMAGE_REPO=${IMAGE_REPO}
IMAGE_TAG=${IMAGE_TAG}
EOF
fi
if [ ! -f .env.runtime ]; then
echo ".env.runtime is missing. Provide IMAGE_REPO and IMAGE_TAG for the deploy." >&2
exit 1
fi
set -a
. ./.env.runtime
set +a
if [ "${PULL_IMAGE:-0}" = "1" ]; then
docker compose -f "$COMPOSE_FILE" pull
fi
docker compose -f "$COMPOSE_FILE" up -d --remove-orphans
docker image prune -f >/dev/null 2>&1 || true