feat: store leads in PostgreSQL instead of SQLite
- server.js uses pg (pinned 8.23.1), reads DATABASE_URL, creates the leads table on start, fails fast if Postgres is unreachable - tests run against a real Postgres in a throwaway schema - CI runs the test image against a throwaway Postgres on DinD - k8s: Postgres 18 StatefulSet (Longhorn, 2Gi), init container wait, password secret, network policy app-to-postgres; app no longer needs a volume or Recreate - README: DBeaver via port-forward, CSV export via docs/export-leads.sql Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
This commit is contained in:
1 parent
5bb2a7343d
commit
f78bd635a2
15 files changed
+508
-166
No files matched your search
+11
-3
@@ -3,8 +3,8 @@ name: CI
|
||||
# Image build for ins-landing-page, following dynamic-qr's pipeline (build container, DinD, one
|
||||
# moving tag per profile, per-branch run queue, guarded microk8s rollout, notifications). The k8s
|
||||
# manifests live in k8s/ and are applied by hand (README "Kubernetes"); CI only rolls the
|
||||
# Deployment so it pulls the new image, and only from main. Tests run inside the Dockerfile's
|
||||
# `test` stage, so a failing test stops the image from being pushed.
|
||||
# Deployment so it pulls the new image, and only from main. Tests run from the Dockerfile's
|
||||
# `test` stage against a throwaway Postgres container, so a failing test stops the push.
|
||||
#
|
||||
# Tags: main -> ins-landing-page-prd-latest; dev -> ins-landing-page-dev-latest.
|
||||
|
||||
@@ -64,7 +64,15 @@ jobs:
|
||||
esac
|
||||
IMAGE_REF="$_REGISTRY/$_REGISTRY_PREFIX/$_IMAGE_NAME:$_REPO_NAME-$PROFILE-latest"
|
||||
printf '%s' "$REGISTRY_PASSWORD" | docker login "$_REGISTRY" -u "$REGISTRY_USER" --password-stdin
|
||||
docker build --pull -f Dockerfile --target test .
|
||||
# Tests need Postgres: run them in the test stage against a throwaway one on its own network.
|
||||
T="ins-ci-$GITHUB_RUN_ID"
|
||||
trap 'docker rm -f "$T-pg" >/dev/null 2>&1; docker network rm "$T" >/dev/null 2>&1' EXIT
|
||||
docker build --pull -f Dockerfile --target test -t "$T-test" .
|
||||
docker network create "$T"
|
||||
docker run -d --name "$T-pg" --network "$T" -e POSTGRES_USER=ci -e POSTGRES_DB=ci -e POSTGRES_PASSWORD=ci postgres:18
|
||||
# -h 127.0.0.1: the image first starts a socket-only init server; TCP answers only once it is really up
|
||||
for i in $(seq 1 30); do docker exec "$T-pg" pg_isready -h 127.0.0.1 -U ci -d ci && break; sleep 2; done
|
||||
docker run --rm --network "$T" -e TEST_DATABASE_URL="postgres://ci:ci@$T-pg:5432/ci" "$T-test"
|
||||
docker build -f Dockerfile -t "$IMAGE_REF" .
|
||||
docker push "$IMAGE_REF"
|
||||
echo "Pushed $IMAGE_REF"
|
||||
|
||||
Reference in new issue
Block a user