351. fix
This commit is contained in:
@@ -1,15 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# EMS single-server deploy: aktualizace git checkoutu, sync compose, docker compose build + up.
|
||||
#
|
||||
# Jednorázový bootstrap na serveru (po prvním merge tohoto skriptu do main):
|
||||
# sudo mkdir -p /opt/ems-deploy/app
|
||||
# sudo chown -R "$USER:$USER" /opt/ems-deploy
|
||||
# git clone ssh://git@git.vojacek.eu:2222/vojacekd/ems.git /opt/ems-deploy/app
|
||||
# cp /opt/ems-deploy/app/.env.example /opt/ems-deploy/.env
|
||||
# # upravit /opt/ems-deploy/.env (chmod 600)
|
||||
# install -m 755 /opt/ems-deploy/app/deploy/deploy.sh /opt/ems-deploy/deploy.sh
|
||||
# /opt/ems-deploy/deploy.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${EMS_DEPLOY_ROOT:-/opt/ems-deploy}"
|
||||
@@ -24,7 +13,7 @@ log() {
|
||||
}
|
||||
|
||||
if [[ ! -d "$APP/.git" ]]; then
|
||||
log "ERROR: missing git checkout at $APP (see bootstrap header in this script)."
|
||||
log "ERROR: missing git checkout at $APP"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -34,26 +23,30 @@ if [[ ! -f "$ENV_FILE" ]]; then
|
||||
fi
|
||||
|
||||
if [[ ! -f "$COMPOSE_SRC" ]]; then
|
||||
log "ERROR: missing $COMPOSE_SRC (is deploy/docker-compose.yml in the repo?)"
|
||||
log "ERROR: missing $COMPOSE_SRC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec 9>"$LOCK_FILE"
|
||||
flock 9
|
||||
|
||||
log "Starting deploy (ROOT=$ROOT)"
|
||||
log "whoami=$(whoami)"
|
||||
log "pwd=$(pwd)"
|
||||
log "app owner=$(stat -c '%u:%g %n' "$APP")"
|
||||
|
||||
log "Git: fetch origin"
|
||||
git -c safe.directory="$APP_DIR" -C "$APP_DIR" fetch origin || true
|
||||
git -c safe.directory="$APP" -C "$APP" fetch origin
|
||||
|
||||
log "Git: checkout main && reset --hard origin/main"
|
||||
git -C "$APP" checkout main
|
||||
git -C "$APP" reset --hard "origin/main"
|
||||
log "Git: checkout main"
|
||||
git -c safe.directory="$APP" -C "$APP" checkout main
|
||||
|
||||
log "Git: reset --hard origin/main"
|
||||
git -c safe.directory="$APP" -C "$APP" reset --hard origin/main
|
||||
|
||||
log "Sync compose -> $COMPOSE_DST"
|
||||
install -m 0644 "$COMPOSE_SRC" "$COMPOSE_DST"
|
||||
|
||||
export COMPOSE_FILE="$COMPOSE_DST"
|
||||
|
||||
log "docker compose config (validate)"
|
||||
docker compose -f "$COMPOSE_DST" --env-file "$ENV_FILE" config >/dev/null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user