diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml deleted file mode 100644 index c2a8468..0000000 --- a/.gitea/workflows/deploy.yml +++ /dev/null @@ -1,57 +0,0 @@ -# Every push to main deploys everything: Traefik first, then each stack under -# stacks/. The runner only uploads; the server validates, deploys and -# smoke-tests (deploy/deploy.sh), so this job needs no Docker of its own. -name: deploy - -on: - push: - branches: [main] - workflow_dispatch: - -# Serializes CI runs; deploy.sh's host lock also covers manual rollbacks. -concurrency: - group: deploy-petrolyst - cancel-in-progress: false - -jobs: - deploy: - runs-on: ubuntu-latest - timeout-minutes: 45 - env: - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} - steps: - - uses: actions/checkout@v4 - - - name: Lint shell scripts - run: | - if ! command -v shellcheck >/dev/null; then - SUDO=$(command -v sudo || true) - $SUDO apt-get update -qq && $SUDO apt-get install -y -qq shellcheck - fi - shellcheck -x host/*.sh deploy/*.sh stacks/*/superset/init.sh stacks/*/fuel-db/init/*.sh - - - name: Install the deploy key - env: - DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} - DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }} - run: | - install -d -m 0700 "$HOME/.ssh" - printf '%s\n' "$DEPLOY_SSH_KEY" > "$HOME/.ssh/deploy_key" - chmod 0600 "$HOME/.ssh/deploy_key" - printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts" - command -v rsync >/dev/null || { SUDO=$(command -v sudo || true); $SUDO apt-get install -y -qq rsync; } - - - name: Upload and deploy - run: | - ssh_cmd="ssh -i $HOME/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts" - # A fresh directory per run; only deploy.sh, under the host lock, - # turns it into releases/. --omit-dir-times: the upload's age - # must be the server's, because retention prunes uploads by mtime. - incoming="/opt/petrolyst/incoming/${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}-$(date -u +%s)" - rsync -az --omit-dir-times --exclude .git -e "$ssh_cmd" ./ "deploy@${DEPLOY_HOST}:${incoming}/" - $ssh_cmd "deploy@${DEPLOY_HOST}" "${incoming}/deploy/deploy.sh" "$GITHUB_SHA" "$incoming" - - - name: Check from outside - run: | - test "$(curl -fsS --max-time 20 https://atoma.petrolyst.com/health)" = OK - curl -fsS --max-time 20 -o /dev/null -w '%{http_code}\n' https://traefik.petrolyst.com/ | grep -qx 302 diff --git a/README.md b/README.md index 14d8d0b..eff10a9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # petrolyst-infra -Everything that runs on the petrolyst server (109.199.127.84, Ubuntu 24.04), deployed on every -push to `main`: +Everything that runs on the petrolyst server (109.199.127.84, Ubuntu 24.04): - **Traefik** at the edge for every project on the server. Its dashboard is at https://traefik.petrolyst.com, behind Keycloak. @@ -9,6 +8,9 @@ push to `main`: store `fuel-db` (Postgres 17 with TimescaleDB) through Trino. Sign-in goes through Keycloak client `petrolyst`, and the UI carries the Petrolyst brand. +**Deploys are manual.** A person deploys a clean commit of `main` from the Mac ("Manual deploy" +under Operating). There is no CI runner, and a push to Gitea deploys nothing. + Customization and deployment are separate, as with media-insights and media-intelligence-docker: | Folder | Holds | @@ -16,19 +18,19 @@ Customization and deployment are separate, as with media-insights and media-inte | `petrolyst-insights/` | how Superset looks and behaves for Petrolyst: config, Keycloak login code, branding, patches, dashboards. See its README. | | `traefik/` | edge proxy, TLS, the `sso` middleware (oauth2-proxy) that guards the dashboard | | `stacks/fuel-monitoring/` | Compose stack, Superset Dockerfile, Trino config and catalog, fuel-db roles | -| `deploy/` | `deploy.sh` (run by CI), `rollback.sh` (manual), `lib.sh` (shared) | +| `deploy/` | `deploy.sh` (run on the server by a manual deploy), `rollback.sh` (manual), `lib.sh` (shared) | | `host/` | one-time server setup: `bootstrap.sh`, `secrets-init.sh` | | `keycloak/` | the `petrolyst` client for Keycloak's partial import | -| `.gitea/workflows/deploy.yml` | the pipeline | No credential is in this repository. Secrets exist only on the server, under -`/opt/petrolyst/secrets/`; CI holds only the SSH deploy key. +`/opt/petrolyst/secrets/`. A deploy needs only root SSH access to the server (`ssh petrolyst`). ## How a deploy works -1. A push to `main` (or a manual run) starts `.gitea/workflows/deploy.yml` on the act_runner. It - lints the scripts, rsyncs the checkout to a fresh `/opt/petrolyst/incoming/-/`, and - calls `deploy/deploy.sh ` over SSH as user `deploy`. +1. A person runs "Manual deploy" (Operating, below) from a clean checkout of `main`: the scripts + are linted, `git archive` sends exactly that commit to a fresh + `/opt/petrolyst/incoming/-manual-