Automate immutable production deployments
This commit is contained in:
@@ -99,17 +99,6 @@ if [[ -n "$registry_username" || -n "$registry_token" ]]; then
|
||||
wm_local_die "WATERMAPS_REGISTRY_USERNAME enthält ungültige Zeichen."
|
||||
fi
|
||||
|
||||
images_env="$(mktemp)"
|
||||
trap 'rm -f "$images_env"' EXIT
|
||||
chmod 0600 "$images_env"
|
||||
{
|
||||
printf 'WATERMAPS_DEPLOY_REVISION=%s\n' "$revision"
|
||||
printf 'WATERMAPS_APP_IMAGE=%s/%s/watermaps:%s\n' \
|
||||
"$registry" "$registry_owner" "$revision"
|
||||
printf 'WATERMAPS_ROUTE_DATA_IMAGE=%s/%s/watermaps-route-data:%s\n' \
|
||||
"$registry" "$registry_owner" "$revision"
|
||||
} >"$images_env"
|
||||
|
||||
wm_local_resolve_ssh "$server_ipv4" "$identity_file"
|
||||
wm_local_wait_for_ssh
|
||||
|
||||
@@ -124,9 +113,9 @@ printf '[watermaps] Warte auf Cloud-init und das persistente Hetzner-Volume.\n'
|
||||
ssh "${WM_SSH_OPTIONS[@]}" "$WM_SSH_TARGET" \
|
||||
"cloud-init status --wait && ${remote_prefix}systemctl start watermaps-volume-setup.service && mountpoint --quiet /srv/watermaps-data"
|
||||
|
||||
printf '[watermaps] Übertrage Deployment-Dateien und Datenbankschema nach %s:/opt/watermaps\n' "$WM_SSH_TARGET"
|
||||
printf '[watermaps] Übertrage Bootstrap-Dateien nach %s:/opt/watermaps\n' "$WM_SSH_TARGET"
|
||||
ssh "${WM_SSH_OPTIONS[@]}" "$WM_SSH_TARGET" \
|
||||
"${remote_prefix}install -d -m 0755 /opt/watermaps /opt/watermaps/deploy /opt/watermaps/database"
|
||||
"${remote_prefix}install -d -m 0755 /opt/watermaps /opt/watermaps/deploy"
|
||||
|
||||
rsync \
|
||||
--archive \
|
||||
@@ -136,18 +125,12 @@ rsync \
|
||||
--rsync-path="$rsync_path" \
|
||||
--exclude='.env.production' \
|
||||
--exclude='.env.images*' \
|
||||
--exclude='.gitea-token' \
|
||||
--exclude='.gitea-*-token' \
|
||||
-e "ssh ${WM_SSH_OPTIONS[*]@Q}" \
|
||||
"$WM_DEPLOY_DIR/" \
|
||||
"$WM_SSH_TARGET:/opt/watermaps/deploy/"
|
||||
|
||||
rsync \
|
||||
--archive \
|
||||
--chmod=F644 \
|
||||
--rsync-path="$rsync_path" \
|
||||
-e "ssh ${WM_SSH_OPTIONS[*]@Q}" \
|
||||
"$WM_LOCAL_ROOT_DIR/database/schema.sql" \
|
||||
"$WM_SSH_TARGET:/opt/watermaps/database/schema.sql"
|
||||
|
||||
rsync \
|
||||
--archive \
|
||||
--chmod=F600 \
|
||||
@@ -156,14 +139,6 @@ rsync \
|
||||
"$local_env" \
|
||||
"$WM_SSH_TARGET:/opt/watermaps/deploy/.env.production"
|
||||
|
||||
rsync \
|
||||
--archive \
|
||||
--chmod=F600 \
|
||||
--rsync-path="$rsync_path" \
|
||||
-e "ssh ${WM_SSH_OPTIONS[*]@Q}" \
|
||||
"$images_env" \
|
||||
"$WM_SSH_TARGET:/opt/watermaps/deploy/.env.images.candidate"
|
||||
|
||||
if [[ -n "$registry_token" ]]; then
|
||||
printf '[watermaps] Aktualisiere den privaten Registry-Login auf dem Server.\n'
|
||||
printf '%s\n' "$registry_token" |
|
||||
@@ -173,14 +148,14 @@ fi
|
||||
|
||||
remote_command="${remote_prefix}chmod +x /opt/watermaps/deploy/scripts/*.sh"
|
||||
remote_command+=" && ${remote_prefix}/opt/watermaps/deploy/scripts/bootstrap-server.sh"
|
||||
remote_command+=" && ${remote_prefix}/opt/watermaps/deploy/scripts/deploy.sh --images-file /opt/watermaps/deploy/.env.images.candidate"
|
||||
remote_command+=" && ${remote_prefix}WATERMAPS_ENV_FILE=/opt/watermaps/deploy/.env.production /opt/watermaps/deploy/scripts/auto-deploy.sh"
|
||||
remote_command+=" && ${remote_prefix}test -L /opt/watermaps/current"
|
||||
remote_command+=" && ${remote_prefix}grep -Fxq 'WATERMAPS_DEPLOY_REVISION=$revision' /opt/watermaps/deploy/.env.images"
|
||||
ssh "${WM_SSH_OPTIONS[@]}" "$WM_SSH_TARGET" "$remote_command"
|
||||
ssh "${WM_SSH_OPTIONS[@]}" "$WM_SSH_TARGET" \
|
||||
"${remote_prefix}rm -f /opt/watermaps/deploy/.env.images.candidate"
|
||||
|
||||
if [[ "$run_go_live" == "true" ]]; then
|
||||
ssh "${WM_SSH_OPTIONS[@]}" "$WM_SSH_TARGET" \
|
||||
"${remote_prefix}/opt/watermaps/deploy/scripts/go-live.sh '$WM_SERVER_IPV4'"
|
||||
"${remote_prefix}WATERMAPS_ENV_FILE=/opt/watermaps/deploy/.env.production /opt/watermaps/current/deploy/scripts/go-live.sh '$WM_SERVER_IPV4'"
|
||||
else
|
||||
printf '[watermaps] Commit %s wurde aus der Registry deployt. Nach dem DNS-Eintrag:\n' "$revision"
|
||||
printf ' ./deploy/scripts/remote-go-live.sh --host %s\n' "$WM_SERVER_IPV4"
|
||||
|
||||
Reference in New Issue
Block a user