Skip to content

Commit 0cc8528

Browse files
committed
docs(issues): add missing container changes to 1525-08 spec
Task 9 was missing two required steps: 1. share/container/entry_script_sh — the container bootstrap script hard-codes only sqlite3 and mysql; without a postgresql elif branch the container exits 1 when that driver is selected. Spec now includes the exact elif block and the updated error message. 2. compose.yaml — the demo compose file only had a mysql service; spec now adds a postgres service (postgres:16, with healthcheck, POSTGRES_DB env var, and a named volume) and updates the tracker's depends_on to include both mysql and postgres. Also extends the overall Acceptance Criteria section with checkboxes for entry_script_sh and compose.yaml.
1 parent ee599dc commit 0cc8528

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

docs/issues/1525-08-add-postgresql-driver.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,18 +625,79 @@ Steps:
625625
626626
- Add `share/default/config/tracker.container.postgresql.toml` as described in the
627627
"What Changes" section.
628+
629+
- Update `share/container/entry_script_sh` to handle `postgresql` alongside the existing
630+
`sqlite3` and `mysql` branches. Add an `elif` branch immediately after the `mysql` branch:
631+
632+
```sh
633+
elif cmp_lc "$TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER" "postgresql"; then
634+
635+
# (no database file needed for PostgreSQL)
636+
637+
# Select default PostgreSQL configuration
638+
default_config="/usr/share/torrust/default/config/tracker.container.postgresql.toml"
639+
```
640+
641+
Also update the error message in the `else` branch to list all three supported backends:
642+
643+
```sh
644+
echo "Please Note: Supported Database Types: \"sqlite3\", \"mysql\", \"postgresql\"."
645+
```
646+
647+
The `Containerfile` already copies this file via
648+
`COPY --chmod=0555 ./share/container/entry_script_sh /usr/local/bin/entry.sh`; no
649+
`Containerfile` changes are needed.
650+
651+
- Update `compose.yaml` to support the PostgreSQL backend alongside the existing MySQL
652+
service:
653+
- Add a `postgres` service using `image: postgres:16`:
654+
655+
```yaml
656+
postgres:
657+
image: postgres:16
658+
healthcheck:
659+
test: ["CMD-SHELL", "pg_isready -U postgres"]
660+
interval: 3s
661+
retries: 5
662+
start_period: 30s
663+
environment:
664+
- POSTGRES_PASSWORD=postgres
665+
- POSTGRES_USER=postgres
666+
- POSTGRES_DB=torrust_tracker
667+
networks:
668+
- server_side
669+
volumes:
670+
- postgres_data:/var/lib/postgresql/data
671+
```
672+
673+
- Add `postgres` to the tracker service's `depends_on` list (alongside `mysql`) so the
674+
tracker waits for whichever backend is healthy. Both DB services start; the tracker
675+
connects to whichever backend the `TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER`
676+
env var selects. This is acceptable for a demo / developer compose file.
677+
678+
- Add a `postgres_data` named volume to the `volumes:` section.
679+
628680
- Update user-facing documentation to document PostgreSQL as a supported backend:
629681
- `README.md` — add `postgresql` to the list of supported database backends.
630682
- `docs/containers.md` — add a section (or extend the existing database section) describing
631683
how to run the tracker with PostgreSQL, including the `POSTGRES_DB` pre-creation
632684
requirement and a reference to the new container config file.
685+
633686
- Run `linter cspell` and add any new technical terms to `project-words.txt` in alphabetical
634687
order. Terms likely to be flagged: `postgresql` (lowercase), `isready`, and any other
635688
identifiers used in scripts or code comments.
636689

637690
Acceptance criteria:
638691

639692
- [ ] `share/default/config/tracker.container.postgresql.toml` exists and is valid TOML.
693+
- [ ] `share/container/entry_script_sh` has a `postgresql` branch that selects
694+
`tracker.container.postgresql.toml`; the `else` error message lists all three supported
695+
backends.
696+
- [ ] `compose.yaml` has a `postgres` service; the tracker service's `depends_on` includes
697+
both `mysql` and `postgres`; a `postgres_data` volume is declared.
698+
- [ ] `docker compose up` with
699+
`TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER=postgresql` starts the tracker
700+
successfully against the PostgreSQL container.
640701
- [ ] The container configuration or its companion documentation (compose file or README)
641702
creates the `torrust_tracker` database (via `POSTGRES_DB` env var or equivalent) before
642703
the tracker is started.
@@ -685,6 +746,12 @@ Acceptance criteria:
685746
- [ ] The benchmark runner produces results for PostgreSQL; `docs/benchmarks/baseline.md`
686747
is updated.
687748
- [ ] `share/default/config/tracker.container.postgresql.toml` exists and is valid TOML.
749+
- [ ] `share/container/entry_script_sh` has a `postgresql` branch; the `else` error message
750+
lists all three supported backends.
751+
- [ ] `compose.yaml` has a `postgres` service; the tracker service's `depends_on` includes
752+
both `mysql` and `postgres`; `docker compose up` with
753+
`TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER=postgresql` starts the tracker
754+
successfully.
688755
- [ ] `project-words.txt` is up to date; `linter cspell` reports no failures.
689756
- [ ] `README.md` lists PostgreSQL as a supported database backend.
690757
- [ ] `docs/containers.md` documents how to run the tracker with PostgreSQL and states the

0 commit comments

Comments
 (0)