askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
docker.yml · 3.0 KB · 81 lines
| 1 | name: Docker |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [main] |
| 6 | pull_request: |
| 7 | branches: [main] |
| 8 | |
| 9 | jobs: |
| 10 | docker: |
| 11 | name: Build, run, and health-check the Docker Compose deployment |
| 12 | runs-on: ubuntu-latest |
| 13 | |
| 14 | steps: |
| 15 | - name: Check out repository |
| 16 | uses: actions/checkout@v4 |
| 17 | |
| 18 | - name: Create .env from .env.example |
| 19 | # No .env is committed (it's git-ignored) -- this mirrors the |
| 20 | # quickstart in docs/docker-deployment.md, which tells a real |
| 21 | # operator to `cp .env.example .env` before their first |
| 22 | # `docker compose up`. Also exercises that .env.example itself is a |
| 23 | # valid, loadable env file. |
| 24 | run: cp .env.example .env |
| 25 | |
| 26 | - name: Build and start the stack |
| 27 | # Matches docs/docker-deployment.md's quickstart |
| 28 | # (`docker compose up --build`) plus `-d` so this step returns |
| 29 | # immediately instead of tailing logs forever in CI. |
| 30 | # |
| 31 | # Retried because pulling the base image from Docker Hub times out |
| 32 | # on GitHub runners often enough to red-X main for reasons that |
| 33 | # have nothing to do with the commit (seen 2026-07-24 on a |
| 34 | # README-only change). A CI that cries wolf trains people to stop |
| 35 | # reading it. Three attempts with backoff; a real build failure |
| 36 | # still fails all three and reports normally. |
| 37 | run: | |
| 38 | for attempt in 1 2 3; do |
| 39 | echo "::group::docker compose up (attempt ${attempt})" |
| 40 | if docker compose up -d --build; then |
| 41 | echo "::endgroup::" |
| 42 | exit 0 |
| 43 | fi |
| 44 | echo "::endgroup::" |
| 45 | echo "attempt ${attempt} failed" |
| 46 | [ "${attempt}" -lt 3 ] && sleep $((attempt * 15)) |
| 47 | done |
| 48 | echo "docker compose up failed three times -- not a transient registry blip" |
| 49 | exit 1 |
| 50 | |
| 51 | - name: Wait for the container to become healthy |
| 52 | run: | |
| 53 | for i in $(seq 1 30); do |
| 54 | status="$(docker inspect --format='{{.State.Health.Status}}' "$(docker compose ps -q object-server)" 2>/dev/null || echo "starting")" |
| 55 | echo "attempt $i: health status = ${status}" |
| 56 | if [ "${status}" = "healthy" ]; then |
| 57 | exit 0 |
| 58 | fi |
| 59 | sleep 2 |
| 60 | done |
| 61 | echo "Container never became healthy within the time budget." >&2 |
| 62 | exit 1 |
| 63 | |
| 64 | - name: Check /health responds successfully |
| 65 | run: curl -fsS http://localhost:8001/health |
| 66 | |
| 67 | - name: Verify the first-boot admin token banner was logged |
| 68 | # scripts/docker-entrypoint.sh generates DBBASIC_ADMIN_TOKEN and |
| 69 | # prints this banner only when no token is set -- .env.example |
| 70 | # leaves DBBASIC_ADMIN_TOKEN unset, so this proves the entrypoint's |
| 71 | # first-boot logic actually ran, not just that it parses. |
| 72 | run: | |
| 73 | docker compose logs object-server | grep -F "DBBASIC: generated a new admin token on first boot." |
| 74 | |
| 75 | - name: Show container logs |
| 76 | if: always() |
| 77 | run: docker compose logs |
| 78 | |
| 79 | - name: Tear down |
| 80 | if: always() |
| 81 | run: docker compose down -v |