♻️ Run database setup explicitly before startup (#2426)

## AI Disclaimer

Using Codex with gpt-5.6-sol. Reviewed manually.
This commit is contained in:
Sebastián Ramírez
2026-08-10 23:09:54 +02:00
committed by GitHub
parent 8893c6807a
commit 9d541082a3
13 changed files with 13 additions and 26 deletions
+1
View File
@@ -33,4 +33,5 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- run: docker compose -f compose.yml -f compose.deploy.yml build - run: docker compose -f compose.yml -f compose.deploy.yml build
- run: docker compose -f compose.yml -f compose.deploy.yml run --rm backend bash scripts/prestart.sh
- run: docker compose -f compose.yml -f compose.deploy.yml up -d - run: docker compose -f compose.yml -f compose.deploy.yml up -d
+1
View File
@@ -33,4 +33,5 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- run: docker compose -f compose.yml -f compose.deploy.yml build - run: docker compose -f compose.yml -f compose.deploy.yml build
- run: docker compose -f compose.yml -f compose.deploy.yml run --rm backend bash scripts/prestart.sh
- run: docker compose -f compose.yml -f compose.deploy.yml up -d - run: docker compose -f compose.yml -f compose.deploy.yml up -d
+1
View File
@@ -78,6 +78,7 @@ jobs:
- run: bash scripts/generate-client.sh - run: bash scripts/generate-client.sh
- run: docker compose build - run: docker compose build
- run: docker compose down -v --remove-orphans - run: docker compose down -v --remove-orphans
- run: docker compose run --rm backend bash scripts/prestart.sh
- name: Run Playwright tests - name: Run Playwright tests
run: docker compose run --rm playwright bunx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} run: docker compose run --rm playwright bunx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- run: docker compose down -v --remove-orphans - run: docker compose down -v --remove-orphans
@@ -20,6 +20,7 @@ jobs:
persist-credentials: false persist-credentials: false
- run: docker compose build - run: docker compose build
- run: docker compose down -v --remove-orphans - run: docker compose down -v --remove-orphans
- run: docker compose run --rm backend bash scripts/prestart.sh
- run: docker compose up -d --wait backend adminer - run: docker compose up -d --wait backend adminer
- name: Test backend is up - name: Test backend is up
run: curl http://localhost:8000/api/v1/utils/health-check run: curl http://localhost:8000/api/v1/utils/health-check
+1
View File
@@ -42,6 +42,7 @@ The setup is also already configured so you can run the tests through the VS Cod
To run the backend and built frontend in Docker Compose: To run the backend and built frontend in Docker Compose:
```console ```console
$ docker compose run --rm backend bash scripts/prestart.sh
$ docker compose watch $ docker compose watch
``` ```
-4
View File
@@ -44,10 +44,6 @@ services:
# Use the Let's Encrypt resolver # Use the Let's Encrypt resolver
- traefik.http.routers.adminer-https.tls.certresolver=le - traefik.http.routers.adminer-https.tls.certresolver=le
prestart:
environment:
FRONTEND_HOST: https://${DOMAIN:?Variable not set}
backend: backend:
restart: always restart: always
environment: environment:
-4
View File
@@ -72,10 +72,6 @@ services:
SMTP_PORT: "1025" SMTP_PORT: "1025"
SMTP_TLS: "false" SMTP_TLS: "false"
prestart:
environment:
ENVIRONMENT: "local"
mailcatcher: mailcatcher:
image: schickling/mailcatcher image: schickling/mailcatcher
ports: ports:
+1 -16
View File
@@ -53,10 +53,7 @@ services:
db: db:
condition: service_healthy condition: service_healthy
restart: true restart: true
prestart: environment:
condition: service_completed_successfully
# The YAML anchor lets the prestart service reuse this environment mapping.
environment: &backend-environment
PROJECT_NAME: ${PROJECT_NAME:?Variable not set} PROJECT_NAME: ${PROJECT_NAME:?Variable not set}
BACKEND_CORS_ORIGINS: ${BACKEND_CORS_ORIGINS:-} BACKEND_CORS_ORIGINS: ${BACKEND_CORS_ORIGINS:-}
SECRET_KEY: ${SECRET_KEY:?Variable not set} SECRET_KEY: ${SECRET_KEY:?Variable not set}
@@ -92,17 +89,5 @@ services:
- traefik.http.routers.backend-http.rule=Host(`${DOMAIN:-localhost}`) - traefik.http.routers.backend-http.rule=Host(`${DOMAIN:-localhost}`)
- traefik.http.routers.backend-http.entrypoints=http - traefik.http.routers.backend-http.entrypoints=http
prestart:
image: backend:latest
build:
context: .
dockerfile: backend/Dockerfile
depends_on:
db:
condition: service_healthy
restart: true
command: bash scripts/prestart.sh
environment: *backend-environment
volumes: volumes:
app-db-data: app-db-data:
+1
View File
@@ -99,6 +99,7 @@ With the environment variables in place, you can deploy with Docker Compose:
```bash ```bash
cd /root/code/app/ cd /root/code/app/
docker compose -f compose.yml -f compose.deploy.yml build docker compose -f compose.yml -f compose.deploy.yml build
docker compose -f compose.yml -f compose.deploy.yml run --rm backend bash scripts/prestart.sh
docker compose -f compose.yml -f compose.deploy.yml up -d docker compose -f compose.yml -f compose.deploy.yml up -d
``` ```
+1
View File
@@ -57,6 +57,7 @@ The build is written to `backend/app/frontend` and served by FastAPI at <http://
To run the backend and built frontend in Docker Compose: To run the backend and built frontend in Docker Compose:
```bash ```bash
docker compose run --rm backend bash scripts/prestart.sh
docker compose watch docker compose watch
``` ```
+3 -2
View File
@@ -15,9 +15,9 @@ bun run dev
* Then open your browser at http://localhost:5173/. * Then open your browser at http://localhost:5173/.
Run the backend locally with `uv run fastapi dev` and PostgreSQL in Docker Compose. See [../development.md](../development.md) for the complete setup. Run `uv run bash scripts/prestart.sh` and `uv run fastapi dev` from the `backend` directory, with PostgreSQL running in Docker Compose. See [../development.md](../development.md) for the complete setup.
To serve the frontend with FastAPI, run `bun run build` from the `frontend` directory and open `http://localhost:8000`. To run the full stack with Docker Compose, use `docker compose watch`. To serve the frontend with FastAPI, run `bun run build` from the `frontend` directory and open `http://localhost:8000`.
Check the file `package.json` to see other available options. Check the file `package.json` to see other available options.
@@ -89,6 +89,7 @@ The frontend code is structured as follows:
The frontend includes initial end-to-end tests using Playwright. To run the tests, you need to have the Docker Compose stack running. Start the stack with the following command: The frontend includes initial end-to-end tests using Playwright. To run the tests, you need to have the Docker Compose stack running. Start the stack with the following command:
```bash ```bash
docker compose run --rm backend bash scripts/prestart.sh
docker compose up -d --wait backend docker compose up -d --wait backend
``` ```
+1
View File
@@ -11,5 +11,6 @@ if [ $(uname -s) = "Linux" ]; then
fi fi
docker-compose build docker-compose build
docker-compose run --rm backend bash scripts/prestart.sh
docker-compose up -d docker-compose up -d
docker-compose exec -T backend bash scripts/tests-start.sh "$@" docker-compose exec -T backend bash scripts/tests-start.sh "$@"
+1
View File
@@ -6,6 +6,7 @@ set -x
docker compose build docker compose build
docker compose down -v --remove-orphans # Remove possibly previous broken stacks left hanging after an error docker compose down -v --remove-orphans # Remove possibly previous broken stacks left hanging after an error
docker compose run --rm backend bash scripts/prestart.sh
docker compose up -d docker compose up -d
docker compose exec -T backend bash scripts/tests-start.sh "$@" docker compose exec -T backend bash scripts/tests-start.sh "$@"
docker compose down -v --remove-orphans docker compose down -v --remove-orphans