Underscore names hezarfen_backend_*
Browse files at this commit6fecf552b0cb3a9c39d74afe9ed6038066875bd6Parent: 57fad2c- chore
- underscore names hezarfen_backend_*
8 changed files +49 -48
- .github/workflows/main.yml +25 -24
- README.md +7 -7
- compose.yaml +10 -10
- deploy/Containerfile.runtime +1 -1
- deploy/backup-postgres.sh +2 -2
- deploy/hezarfen_backend.env.example +1 -1
- deploy/hezarfen-compose.service → deploy/hezarfen_backend_compose.service +2 -2
- scripts/prepare_db.sh +1 -1
.github/workflows/main.ymlmodified+25 -24
| @@ -7,7 +7,7 @@ | |||
| 7 | # artifact. | 7 | # artifact. |
| 8 | # Deploy — SSH: podman load the image, point the deploy-owned | 8 | # Deploy — SSH: podman load the image, point the deploy-owned |
| 9 | # stack.env's HEZARFEN_TAG at it, install compose.yaml + | 9 | # stack.env's HEZARFEN_TAG at it, install compose.yaml + |
| 10 | -# the hezarfen-compose user unit + the backup script, | 10 | +# the hezarfen_backend_compose user unit + the backup script, |
| 11 | # restart the stack, /health-gated rollback to the | 11 | # restart the stack, /health-gated rollback to the |
| 12 | # previous tag, independent after-the-fact verify. | 12 | # previous tag, independent after-the-fact verify. |
| 13 | # | 13 | # |
| @@ -20,7 +20,7 @@ | |||
| 20 | # lag HEAD while a push is mid-CI, and that is the point: redeploy the | 20 | # lag HEAD while a push is mid-CI, and that is the point: redeploy the |
| 21 | # known-good image, e.g. after a server-side fix (env file, proxy, | 21 | # known-good image, e.g. after a server-side fix (env file, proxy, |
| 22 | # database). For env-only changes a plain | 22 | # database). For env-only changes a plain |
| 23 | -# `ssh <vps> 'systemctl --user restart hezarfen-compose'` needs no | 23 | +# `ssh <vps> 'systemctl --user restart hezarfen_backend_compose'` needs no |
| 24 | # workflow at all: the stack re-reads its env files on the next | 24 | # workflow at all: the stack re-reads its env files on the next |
| 25 | # `podman compose up`. | 25 | # `podman compose up`. |
| 26 | # | 26 | # |
| @@ -61,8 +61,8 @@ env: | |||
| 61 | # and the linker is rustc's default bundled lld. | 61 | # and the linker is rustc's default bundled lld. |
| 62 | TARGET: x86_64-unknown-linux-gnu | 62 | TARGET: x86_64-unknown-linux-gnu |
| 63 | # The systemd user unit that wraps `podman compose`. See | 63 | # The systemd user unit that wraps `podman compose`. See |
| 64 | - # deploy/hezarfen-compose.service. | 64 | + # deploy/hezarfen_backend_compose.service. |
| 65 | - SERVICE: hezarfen-compose | 65 | + SERVICE: hezarfen_backend_compose |
| 66 | # The deploy lives in this subdirectory of the SSH user's home. The home | 66 | # The deploy lives in this subdirectory of the SSH user's home. The home |
| 67 | # itself is resolved on the server ($HOME), so switching the deploy user | 67 | # itself is resolved on the server ($HOME), so switching the deploy user |
| 68 | # moves the path with it — a baked-in absolute path once kept pointing at | 68 | # moves the path with it — a baked-in absolute path once kept pointing at |
| @@ -136,15 +136,15 @@ jobs: | |||
| 136 | # same 500 the compose stack runs (see compose.yaml). | 136 | # same 500 the compose stack runs (see compose.yaml). |
| 137 | - name: Start Postgres | 137 | - name: Start Postgres |
| 138 | run: | | 138 | run: | |
| 139 | - docker run -d --name hezarfen-pg \ | 139 | + docker run -d --name hezarfen_backend_pg \ |
| 140 | -e POSTGRES_USER="$PG_USER" -e POSTGRES_PASSWORD="$PG_PASSWORD" \ | 140 | -e POSTGRES_USER="$PG_USER" -e POSTGRES_PASSWORD="$PG_PASSWORD" \ |
| 141 | -p 127.0.0.1:5432:5432 \ | 141 | -p 127.0.0.1:5432:5432 \ |
| 142 | postgres:18-alpine -c max_connections=500 | 142 | postgres:18-alpine -c max_connections=500 |
| 143 | for _ in $(seq 1 30); do | 143 | for _ in $(seq 1 30); do |
| 144 | - docker exec hezarfen-pg pg_isready -U "$PG_USER" && break | 144 | + docker exec hezarfen_backend_pg pg_isready -U "$PG_USER" && break |
| 145 | sleep 1 | 145 | sleep 1 |
| 146 | done | 146 | done |
| 147 | - docker exec hezarfen-pg pg_isready -U "$PG_USER" | 147 | + docker exec hezarfen_backend_pg pg_isready -U "$PG_USER" |
| 148 | 148 | ||
| 149 | - name: Install cargo-nextest | 149 | - name: Install cargo-nextest |
| 150 | uses: taiki-e/install-action@v2 | 150 | uses: taiki-e/install-action@v2 |
| @@ -179,21 +179,21 @@ jobs: | |||
| 179 | # Pack the already-built, already-stripped gnu binary into the | 179 | # Pack the already-built, already-stripped gnu binary into the |
| 180 | # runtime image. Never build from source here: a second rust | 180 | # runtime image. Never build from source here: a second rust |
| 181 | # compile blows the runner's disk. | 181 | # compile blows the runner's disk. |
| 182 | - docker build -f deploy/Containerfile.runtime -t localhost/hezarfen-backend:$GITHUB_SHA stage/ | 182 | + docker build -f deploy/Containerfile.runtime -t localhost/hezarfen_backend:$GITHUB_SHA stage/ |
| 183 | - docker save localhost/hezarfen-backend:$GITHUB_SHA | gzip > stage/hezarfen-backend.tar.gz | 183 | + docker save localhost/hezarfen_backend:$GITHUB_SHA | gzip > stage/hezarfen_backend.tar.gz |
| 184 | 184 | ||
| 185 | - name: Stage the compose bundle | 185 | - name: Stage the compose bundle |
| 186 | run: | | 186 | run: | |
| 187 | set -euo pipefail | 187 | set -euo pipefail |
| 188 | - cp compose.yaml deploy/hezarfen-compose.service deploy/backup-postgres.sh stage/ | 188 | + cp compose.yaml deploy/hezarfen_backend_compose.service deploy/backup-postgres.sh stage/ |
| 189 | echo -n "$GITHUB_SHA" > stage/tag | 189 | echo -n "$GITHUB_SHA" > stage/tag |
| 190 | # Everything the deploy installs on the server must be here; a | 190 | # Everything the deploy installs on the server must be here; a |
| 191 | # missing piece fails here, on the runner, not mid-deploy on the | 191 | # missing piece fails here, on the runner, not mid-deploy on the |
| 192 | # VPS. The raw binary and migrations may linger as docker build | 192 | # VPS. The raw binary and migrations may linger as docker build |
| 193 | # context — they are no longer load-bearing. | 193 | # context — they are no longer load-bearing. |
| 194 | - test -f stage/hezarfen-backend.tar.gz | 194 | + test -f stage/hezarfen_backend.tar.gz |
| 195 | test -f stage/compose.yaml | 195 | test -f stage/compose.yaml |
| 196 | - test -f stage/hezarfen-compose.service | 196 | + test -f stage/hezarfen_backend_compose.service |
| 197 | test -f stage/backup-postgres.sh | 197 | test -f stage/backup-postgres.sh |
| 198 | test -f stage/tag | 198 | test -f stage/tag |
| 199 | ls -l stage | 199 | ls -l stage |
| @@ -268,9 +268,9 @@ jobs: | |||
| 268 | - name: Check the release is complete | 268 | - name: Check the release is complete |
| 269 | run: | | 269 | run: | |
| 270 | set -euo pipefail | 270 | set -euo pipefail |
| 271 | - test -f stage/hezarfen-backend.tar.gz | 271 | + test -f stage/hezarfen_backend.tar.gz |
| 272 | test -f stage/compose.yaml | 272 | test -f stage/compose.yaml |
| 273 | - test -f stage/hezarfen-compose.service | 273 | + test -f stage/hezarfen_backend_compose.service |
| 274 | test -f stage/backup-postgres.sh | 274 | test -f stage/backup-postgres.sh |
| 275 | test -f stage/tag | 275 | test -f stage/tag |
| 276 | 276 | ||
| @@ -311,7 +311,7 @@ jobs: | |||
| 311 | # and would not expand $HOME. Only the five deploy files ship — | 311 | # and would not expand $HOME. Only the five deploy files ship — |
| 312 | # the raw binary and migrations stay on the runner (they were | 312 | # the raw binary and migrations stay on the runner (they were |
| 313 | # docker build context, nothing more). | 313 | # docker build context, nothing more). |
| 314 | - tar -C stage -czf - hezarfen-backend.tar.gz compose.yaml hezarfen-compose.service backup-postgres.sh tag | ssh "$ssh_target" "bash -c 'exec tar -xzf - -C \"\$HOME/\$1\"' -- '$DEPLOY_SUBDIR'" | 314 | + tar -C stage -czf - hezarfen_backend.tar.gz compose.yaml hezarfen_backend_compose.service backup-postgres.sh tag | ssh "$ssh_target" "bash -c 'exec tar -xzf - -C \"\$HOME/\$1\"' -- '$DEPLOY_SUBDIR'" |
| 315 | 315 | ||
| 316 | - name: Load the image and restart the stack | 316 | - name: Load the image and restart the stack |
| 317 | run: | | 317 | run: | |
| @@ -362,7 +362,7 @@ jobs: | |||
| 362 | 362 | ||
| 363 | # Load THIS build's image and read the tag the build stamped into | 363 | # Load THIS build's image and read the tag the build stamped into |
| 364 | # it (build time and deploy time must agree on what is shipping). | 364 | # it (build time and deploy time must agree on what is shipping). |
| 365 | - gunzip -c "$deploy_path/hezarfen-backend.tar.gz" | podman load | 365 | + gunzip -c "$deploy_path/hezarfen_backend.tar.gz" | podman load |
| 366 | tag=$(cat -- "$deploy_path/tag") | 366 | tag=$(cat -- "$deploy_path/tag") |
| 367 | 367 | ||
| 368 | # Tag rotation: previous_tag is the rollback target (absent on a | 368 | # Tag rotation: previous_tag is the rollback target (absent on a |
| @@ -379,11 +379,11 @@ jobs: | |||
| 379 | 379 | ||
| 380 | # The freshly extracted bundle: compose file and unit are | 380 | # The freshly extracted bundle: compose file and unit are |
| 381 | # world-readable, the backup script is run by hand or a timer. | 381 | # world-readable, the backup script is run by hand or a timer. |
| 382 | - chmod 0644 -- "$deploy_path/compose.yaml" "$deploy_path/hezarfen-compose.service" | 382 | + chmod 0644 -- "$deploy_path/compose.yaml" "$deploy_path/hezarfen_backend_compose.service" |
| 383 | chmod 0755 -- "$deploy_path/backup-postgres.sh" | 383 | chmod 0755 -- "$deploy_path/backup-postgres.sh" |
| 384 | # The image tarball was only a transport; the image is loaded into | 384 | # The image tarball was only a transport; the image is loaded into |
| 385 | # podman's storage now. | 385 | # podman's storage now. |
| 386 | - rm -f -- "$deploy_path/hezarfen-backend.tar.gz" | 386 | + rm -f -- "$deploy_path/hezarfen_backend.tar.gz" |
| 387 | 387 | ||
| 388 | compose_up() { | 388 | compose_up() { |
| 389 | podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" up -d --no-build | 389 | podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" up -d --no-build |
| @@ -408,11 +408,12 @@ jobs: | |||
| 408 | # no unit until the first deploy writes it, and a changed unit | 408 | # no unit until the first deploy writes it, and a changed unit |
| 409 | # lands with the compose file that needs it. | 409 | # lands with the compose file that needs it. |
| 410 | mkdir -p -- "$HOME/.config/systemd/user" | 410 | mkdir -p -- "$HOME/.config/systemd/user" |
| 411 | - install -m 0644 -- "$deploy_path/hezarfen-compose.service" "$HOME/.config/systemd/user/$service.service" | 411 | + install -m 0644 -- "$deploy_path/hezarfen_backend_compose.service" "$HOME/.config/systemd/user/$service.service" |
| 412 | systemctl --user daemon-reload | 412 | systemctl --user daemon-reload |
| 413 | - # Retire the binary-era unit: disable it (absent on fresh boxes) | 413 | + # Retire leftover units: the binary-era hezarfen.service and the |
| 414 | - # and drop its unit file so it can never come back at boot. | 414 | + # hyphenated hezarfen-compose.service from the first compose cut. |
| 415 | systemctl --user disable --now hezarfen.service 2>/dev/null || true; rm -f -- "$HOME/.config/systemd/user/hezarfen.service" | 415 | systemctl --user disable --now hezarfen.service 2>/dev/null || true; rm -f -- "$HOME/.config/systemd/user/hezarfen.service" |
| 416 | + systemctl --user disable --now hezarfen-compose.service 2>/dev/null || true; rm -f -- "$HOME/.config/systemd/user/hezarfen-compose.service" | ||
| 416 | 417 | ||
| 417 | # The unit is a oneshot with RemainAfterExit, so `start` on the | 418 | # The unit is a oneshot with RemainAfterExit, so `start` on the |
| 418 | # active (exited) unit would be a no-op — every deploy restarts | 419 | # active (exited) unit would be a no-op — every deploy restarts |
| @@ -444,7 +445,7 @@ jobs: | |||
| 444 | 445 | ||
| 445 | # A stale stack from an older deploy can answer too, so the | 446 | # A stale stack from an older deploy can answer too, so the |
| 446 | # running container must be THIS build's image, or it rolls back. | 447 | # running container must be THIS build's image, or it rolls back. |
| 447 | - image=$(podman inspect -f '{{.Config.Image}}' hezarfen-backend) | 448 | + image=$(podman inspect -f '{{.Config.Image}}' hezarfen_backend) |
| 448 | case "$image" in | 449 | case "$image" in |
| 449 | *"$tag"*) ;; | 450 | *"$tag"*) ;; |
| 450 | *) | 451 | *) |
| @@ -453,7 +454,7 @@ jobs: | |||
| 453 | exit 1 | 454 | exit 1 |
| 454 | ;; | 455 | ;; |
| 455 | esac | 456 | esac |
| 456 | - echo 'hezarfen-compose is up' | 457 | + echo 'hezarfen_backend_compose is up' |
| 457 | REMOTE | 458 | REMOTE |
| 458 | 459 | ||
| 459 | # The independent after-the-fact check: the container answering must | 460 | # The independent after-the-fact check: the container answering must |
| @@ -472,7 +473,7 @@ jobs: | |||
| 472 | export XDG_RUNTIME_DIR=/run/user/$(id -u) | 473 | export XDG_RUNTIME_DIR=/run/user/$(id -u) |
| 473 | cd -- "$deploy_path" | 474 | cd -- "$deploy_path" |
| 474 | tag=$(cat -- "$deploy_path/current_tag") | 475 | tag=$(cat -- "$deploy_path/current_tag") |
| 475 | - image=$(podman inspect -f '{{.Config.Image}}' hezarfen-backend) | 476 | + image=$(podman inspect -f '{{.Config.Image}}' hezarfen_backend) |
| 476 | case "$image" in | 477 | case "$image" in |
| 477 | *"$tag"*) ;; | 478 | *"$tag"*) ;; |
| 478 | *) | 479 | *) |
README.mdmodified+7 -7
| @@ -249,7 +249,7 @@ reachable (`HOST` is forced to `0.0.0.0` inside the container so the publish | |||
| 249 | works). Each service has its own named volume: `pgdata` holds the database | 249 | works). Each service has its own named volume: `pgdata` holds the database |
| 250 | — it is mounted at `/var/lib/postgresql`, which the postgres:18 image keeps | 250 | — it is mounted at `/var/lib/postgresql`, which the postgres:18 image keeps |
| 251 | its cluster under (`/var/lib/postgresql/18/docker`), so the data really | 251 | its cluster under (`/var/lib/postgresql/18/docker`), so the data really |
| 252 | -lands in the volume — and `hezarfen-data` holds the | 252 | +lands in the volume — and `hezarfen_backend_data` holds the |
| 253 | uploaded note files (`/data/files`). Production knobs (`COOKIE_SECURE`, | 253 | uploaded note files (`/data/files`). Production knobs (`COOKIE_SECURE`, |
| 254 | `CORS_ALLOWED_ORIGINS`, rate limits, `TRUST_PROXY`) reach the backend through | 254 | `CORS_ALLOWED_ORIGINS`, rate limits, `TRUST_PROXY`) reach the backend through |
| 255 | the env file (below), not through `compose.yaml`. Leaving | 255 | the env file (below), not through `compose.yaml`. Leaving |
| @@ -303,19 +303,19 @@ shipped with the deploy artifact and living next to `compose.yaml` on the VPS | |||
| 303 | the control database and all of them. Restore with: | 303 | the control database and all of them. Restore with: |
| 304 | 304 | ||
| 305 | ```sh | 305 | ```sh |
| 306 | -gunzip -c backups/FILE.sql.gz | podman exec -i hezarfen-postgres psql -U hezarfen -d postgres | 306 | +gunzip -c backups/FILE.sql.gz | podman exec -i hezarfen_backend_postgres psql -U hezarfen -d postgres |
| 307 | ``` | 307 | ``` |
| 308 | 308 | ||
| 309 | Deploying is GitHub Actions' job, not the server's: the workflow packs the | 309 | Deploying is GitHub Actions' job, not the server's: the workflow packs the |
| 310 | already-built binary and the migrations into a runtime image | 310 | already-built binary and the migrations into a runtime image |
| 311 | (`deploy/Containerfile.runtime`), ships the image tarball together with | 311 | (`deploy/Containerfile.runtime`), ships the image tarball together with |
| 312 | -`compose.yaml`, the `hezarfen-compose.service` unit and the backup script as | 312 | +`compose.yaml`, the `hezarfen_backend_compose.service` unit and the backup script as |
| 313 | an artifact, and the deploy job loads it on the VPS and starts the stack with | 313 | an artifact, and the deploy job loads it on the VPS and starts the stack with |
| 314 | `podman compose up -d --no-build` — the image tag travels in a deploy-owned | 314 | `podman compose up -d --no-build` — the image tag travels in a deploy-owned |
| 315 | `stack.env`, so a release never rewrites the operator's secrets file. The | 315 | `stack.env`, so a release never rewrites the operator's secrets file. The |
| 316 | operator's only manual step is writing the env file once (above). Reboots | 316 | operator's only manual step is writing the env file once (above). Reboots |
| 317 | heal themselves: the user session lingers (`loginctl enable-linger`) and the | 317 | heal themselves: the user session lingers (`loginctl enable-linger`) and the |
| 318 | -`hezarfen-compose.service` user unit runs compose again at boot. | 318 | +`hezarfen_backend_compose.service` user unit runs compose again at boot. |
| 319 | 319 | ||
| 320 | The backend survives the database going away, at boot and at runtime. | 320 | The backend survives the database going away, at boot and at runtime. |
| 321 | 321 | ||
| @@ -337,8 +337,8 @@ request; there is nothing to re-arm. | |||
| 337 | Without compose: | 337 | Without compose: |
| 338 | 338 | ||
| 339 | ```sh | 339 | ```sh |
| 340 | -podman build -t hezarfen-backend . | 340 | +podman build -t hezarfen_backend . |
| 341 | -podman run -d --name hezarfen -p 7656:7656 -v hezarfen-data:/data hezarfen-backend | 341 | +podman run -d --name hezarfen -p 7656:7656 -v hezarfen_backend_data:/data hezarfen_backend |
| 342 | ``` | 342 | ``` |
| 343 | 343 | ||
| 344 | ## Multi-school (SaaS) | 344 | ## Multi-school (SaaS) |
| @@ -1012,7 +1012,7 @@ UPDATE app_user SET role = 'admin' WHERE username = 'ada'; | |||
| 1012 | 1012 | ||
| 1013 | against the **school's** database (`{control}_school_{uuid hex}` — the hex of | 1013 | against the **school's** database (`{control}_school_{uuid hex}` — the hex of |
| 1014 | the school's registry `id`, no dashes), not the control one. List the school | 1014 | the school's registry `id`, no dashes), not the control one. List the school |
| 1015 | -databases with `\l` — e.g. `podman exec -it hezarfen-postgres psql -U hezarfen | 1015 | +databases with `\l` — e.g. `podman exec -it hezarfen_backend_postgres psql -U hezarfen |
| 1016 | -d hezarfen_control -c "SELECT slug, id FROM school"` names each school and | 1016 | -d hezarfen_control -c "SELECT slug, id FROM school"` names each school and |
| 1017 | its database suffix for the compose stack. | 1017 | its database suffix for the compose stack. |
| 1018 | 1018 | ||
compose.yamlmodified+10 -10
| @@ -18,7 +18,7 @@ | |||
| 18 | services: | 18 | services: |
| 19 | postgres: | 19 | postgres: |
| 20 | image: docker.io/library/postgres:18-alpine | 20 | image: docker.io/library/postgres:18-alpine |
| 21 | - container_name: hezarfen-postgres | 21 | + container_name: hezarfen_backend_postgres |
| 22 | # 500 connections: the test suite mints a control+school pool per test | 22 | # 500 connections: the test suite mints a control+school pool per test |
| 23 | # (nextest runs ~a dozen concurrently), which exhausts the 100 default. | 23 | # (nextest runs ~a dozen concurrently), which exhausts the 100 default. |
| 24 | command: ["postgres", "-c", "max_connections=500"] | 24 | command: ["postgres", "-c", "max_connections=500"] |
| @@ -32,7 +32,7 @@ services: | |||
| 32 | # postgres:18 declares VOLUME /var/lib/postgresql (PGDATA is | 32 | # postgres:18 declares VOLUME /var/lib/postgresql (PGDATA is |
| 33 | # /var/lib/postgresql/18/docker); mounting the parent keeps the whole | 33 | # /var/lib/postgresql/18/docker); mounting the parent keeps the whole |
| 34 | # data dir — including future major-version subdirs — in the volume. | 34 | # data dir — including future major-version subdirs — in the volume. |
| 35 | - - pgdata:/var/lib/postgresql | 35 | + - hezarfen_backend_pgdata:/var/lib/postgresql |
| 36 | restart: unless-stopped | 36 | restart: unless-stopped |
| 37 | healthcheck: | 37 | healthcheck: |
| 38 | # $$ keeps compose from interpolating; the shell inside the container | 38 | # $$ keeps compose from interpolating; the shell inside the container |
| @@ -49,8 +49,8 @@ services: | |||
| 49 | dockerfile: Containerfile | 49 | dockerfile: Containerfile |
| 50 | # HEZARFEN_TAG comes from the deploy-owned stack.env (--env-file), or the | 50 | # HEZARFEN_TAG comes from the deploy-owned stack.env (--env-file), or the |
| 51 | # latest local build on a laptop. | 51 | # latest local build on a laptop. |
| 52 | - image: localhost/hezarfen-backend:${HEZARFEN_TAG:-latest} | 52 | + image: localhost/hezarfen_backend:${HEZARFEN_TAG:-latest} |
| 53 | - container_name: hezarfen-backend | 53 | + container_name: hezarfen_backend |
| 54 | ports: | 54 | ports: |
| 55 | # Loopback only: terminate TLS on a reverse proxy in front of this. | 55 | # Loopback only: terminate TLS on a reverse proxy in front of this. |
| 56 | - "127.0.0.1:7656:7656" | 56 | - "127.0.0.1:7656:7656" |
| @@ -82,7 +82,7 @@ services: | |||
| 82 | # Every service must present this to register. | 82 | # Every service must present this to register. |
| 83 | AI_SHARED_TOKEN: ${AI_SHARED_TOKEN:-change-me} | 83 | AI_SHARED_TOKEN: ${AI_SHARED_TOKEN:-change-me} |
| 84 | volumes: | 84 | volumes: |
| 85 | - - hezarfen-data:/data | 85 | + - hezarfen_backend_data:/data |
| 86 | depends_on: | 86 | depends_on: |
| 87 | postgres: | 87 | postgres: |
| 88 | condition: service_healthy | 88 | condition: service_healthy |
| @@ -102,7 +102,7 @@ services: | |||
| 102 | # when OTEL_* keys are present in hezarfen_backend.env (see the example). | 102 | # when OTEL_* keys are present in hezarfen_backend.env (see the example). |
| 103 | openobserve: | 103 | openobserve: |
| 104 | image: docker.io/openobserve/openobserve:v1.0.0-rc2 | 104 | image: docker.io/openobserve/openobserve:v1.0.0-rc2 |
| 105 | - container_name: hezarfen-openobserve | 105 | + container_name: hezarfen_backend_openobserve |
| 106 | environment: | 106 | environment: |
| 107 | # First-boot root account, created once. OpenObserve enforces a password | 107 | # First-boot root account, created once. OpenObserve enforces a password |
| 108 | # policy (8-128 chars, upper + lower + digit + special) and panics on | 108 | # policy (8-128 chars, upper + lower + digit + special) and panics on |
| @@ -117,7 +117,7 @@ services: | |||
| 117 | - "127.0.0.1:5080:5080" | 117 | - "127.0.0.1:5080:5080" |
| 118 | - "127.0.0.1:5081:5081" | 118 | - "127.0.0.1:5081:5081" |
| 119 | volumes: | 119 | volumes: |
| 120 | - - openobserve-data:/data | 120 | + - hezarfen_backend_openobserve_data:/data |
| 121 | restart: unless-stopped | 121 | restart: unless-stopped |
| 122 | healthcheck: | 122 | healthcheck: |
| 123 | # corner-cut: the image is distroless (only /openobserve, no shell and no | 123 | # corner-cut: the image is distroless (only /openobserve, no shell and no |
| @@ -133,6 +133,6 @@ services: | |||
| 133 | start_period: 10s | 133 | start_period: 10s |
| 134 | 134 | ||
| 135 | volumes: | 135 | volumes: |
| 136 | - hezarfen-data: | 136 | + hezarfen_backend_data: |
| 137 | - pgdata: | 137 | + hezarfen_backend_pgdata: |
| 138 | - openobserve-data: | 138 | + hezarfen_backend_openobserve_data: |
deploy/Containerfile.runtimemodified+1 -1
| @@ -5,7 +5,7 @@ | |||
| 5 | # | 5 | # |
| 6 | # Build context is stage/, populated by CI: | 6 | # Build context is stage/, populated by CI: |
| 7 | # docker build -f deploy/Containerfile.runtime \ | 7 | # docker build -f deploy/Containerfile.runtime \ |
| 8 | -# -t localhost/hezarfen-backend:$GITHUB_SHA stage/ | 8 | +# -t localhost/hezarfen_backend:$GITHUB_SHA stage/ |
| 9 | # with stage/hezarfen_backend (the binary) and stage/migrations/. | 9 | # with stage/hezarfen_backend (the binary) and stage/migrations/. |
| 10 | FROM docker.io/library/debian:trixie-slim | 10 | FROM docker.io/library/debian:trixie-slim |
| 11 | 11 | ||
deploy/backup-postgres.shmodified+2 -2
| @@ -8,7 +8,7 @@ | |||
| 8 | # 20 4 * * * $HOME/hezarfen_backend/backup-postgres.sh | 8 | # 20 4 * * * $HOME/hezarfen_backend/backup-postgres.sh |
| 9 | # | 9 | # |
| 10 | # Restore (from ~/hezarfen_backend): | 10 | # Restore (from ~/hezarfen_backend): |
| 11 | -# gunzip -c backups/FILE.sql.gz | podman exec -i hezarfen-postgres psql -U hezarfen -d postgres | 11 | +# gunzip -c backups/FILE.sql.gz | podman exec -i hezarfen_backend_postgres psql -U hezarfen -d postgres |
| 12 | set -euo pipefail | 12 | set -euo pipefail |
| 13 | 13 | ||
| 14 | dir="$(cd "$(dirname "$0")" && pwd)" | 14 | dir="$(cd "$(dirname "$0")" && pwd)" |
| @@ -22,5 +22,5 @@ user="${user:-hezarfen}" | |||
| 22 | out="$dir/backups/hezarfen-$(date -u +%Y%m%dT%H%M%SZ).sql.gz" | 22 | out="$dir/backups/hezarfen-$(date -u +%Y%m%dT%H%M%SZ).sql.gz" |
| 23 | umask 077 | 23 | umask 077 |
| 24 | # pipefail (set above): a failed pg_dumpall must not leave a "good" empty dump. | 24 | # pipefail (set above): a failed pg_dumpall must not leave a "good" empty dump. |
| 25 | -podman exec hezarfen-postgres pg_dumpall -U "$user" | gzip > "$out" | 25 | +podman exec hezarfen_backend_postgres pg_dumpall -U "$user" | gzip > "$out" |
| 26 | echo "wrote $out ($(du -h "$out" | cut -f1))" | 26 | echo "wrote $out ($(du -h "$out" | cut -f1))" |
deploy/hezarfen_backend.env.examplemodified+1 -1
| @@ -56,7 +56,7 @@ AI_SHARED_TOKEN= | |||
| 56 | # printf '%s:%s' 'admin@example.com' 'PASSWORD' | base64 | 56 | # printf '%s:%s' 'admin@example.com' 'PASSWORD' | base64 |
| 57 | #OTEL_EXPORTER_OTLP_ENDPOINT=http://openobserve:5081 | 57 | #OTEL_EXPORTER_OTLP_ENDPOINT=http://openobserve:5081 |
| 58 | #OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <base64>,organization=default,stream-name=default | 58 | #OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic <base64>,organization=default,stream-name=default |
| 59 | -#OTEL_SERVICE_NAME=hezarfen-backend | 59 | +#OTEL_SERVICE_NAME=hezarfen_backend |
| 60 | # Names the deployment in every exported signal. | 60 | # Names the deployment in every exported signal. |
| 61 | #DEPLOY_ENV=production | 61 | #DEPLOY_ENV=production |
| 62 | 62 | ||
deploy/hezarfen-compose.service → deploy/hezarfen_backend_compose.servicerenamed+2 -2
| @@ -25,7 +25,7 @@ | |||
| 25 | # | 25 | # |
| 26 | # Env-only restart (restart re-runs `compose up -d`, recreating containers | 26 | # Env-only restart (restart re-runs `compose up -d`, recreating containers |
| 27 | # whose environment changed): | 27 | # whose environment changed): |
| 28 | -# systemctl --user restart hezarfen-compose | 28 | +# systemctl --user restart hezarfen_backend_compose |
| 29 | 29 | ||
| 30 | [Unit] | 30 | [Unit] |
| 31 | Description=Hezarfen backend compose stack (postgres + backend + openobserve) | 31 | Description=Hezarfen backend compose stack (postgres + backend + openobserve) |
| @@ -39,7 +39,7 @@ WorkingDirectory=%h/hezarfen_backend | |||
| 39 | # Later --env-file wins for duplicate keys: the operator's secrets file | 39 | # Later --env-file wins for duplicate keys: the operator's secrets file |
| 40 | # first, the deploy-owned stack.env (HEZARFEN_TAG) second. | 40 | # first, the deploy-owned stack.env (HEZARFEN_TAG) second. |
| 41 | ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_backend/hezarfen_backend.env --env-file %h/hezarfen_backend/stack.env up -d --no-build | 41 | ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_backend/hezarfen_backend.env --env-file %h/hezarfen_backend/stack.env up -d --no-build |
| 42 | -# No -v: the pgdata/hezarfen-data/openobserve-data volumes must survive stop. | 42 | +# No -v: named volumes must survive stop. |
| 43 | ExecStop=/usr/bin/podman compose down | 43 | ExecStop=/usr/bin/podman compose down |
| 44 | TimeoutStartSec=180 | 44 | TimeoutStartSec=180 |
| 45 | 45 | ||
scripts/prepare_db.shmodified+1 -1
| @@ -17,7 +17,7 @@ | |||
| 17 | # Requires the compose Postgres: `podman compose up -d postgres`. | 17 | # Requires the compose Postgres: `podman compose up -d postgres`. |
| 18 | set -euo pipefail | 18 | set -euo pipefail |
| 19 | 19 | ||
| 20 | -CONTAINER="${HEZARFEN_PG_CONTAINER:-hezarfen-postgres}" | 20 | +CONTAINER="${HEZARFEN_PG_CONTAINER:-hezarfen_backend_postgres}" |
| 21 | PREPARE_DB="${HEZARFEN_PREPARE_DB:-hezarfen_sqlx_prepare}" | 21 | PREPARE_DB="${HEZARFEN_PREPARE_DB:-hezarfen_sqlx_prepare}" |
| 22 | HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | 22 | HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 23 | 23 | ||