From 66d8cdf9b2820b9afe8d346759310d2aedaecca5 Mon Sep 17 00:00:00 2001 From: default Date: Fri, 5 Jun 2026 01:19:10 +0000 Subject: [PATCH] Add self-hosted Postgres docker-compose - docker-compose.yml: Postgres 16 Alpine with named volume, healthcheck - .env.example: POSTGRES_* and DATABASE_URL template - .gitignore: exclude db_data/ volume Starting fresh, no data migration. App still wired to Supabase; DB is ready for migrations to be applied. --- .env.example | 15 +++++++++++++++ .gitignore | 4 +++- docker-compose.yml | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1448d7c --- /dev/null +++ b/.env.example @@ -0,0 +1,15 @@ +# --- Self-hosted Postgres (Docker) --- +POSTGRES_USER=routecommerce +POSTGRES_PASSWORD=change-me-strong-password +POSTGRES_DB=route_commerce +# Used by the app and push-migrations.js to talk to the local DB +DATABASE_URL=postgresql://routecommerce:change-me-strong-password@127.0.0.1:5432/route_commerce?schema=public + +# --- Supabase (legacy, can be removed once app is rewired) --- +NEXT_PUBLIC_SUPABASE_URL= +NEXT_PUBLIC_SUPABASE_ANON_KEY= +SUPABASE_SERVICE_ROLE_KEY= + +# --- App secrets --- +MINIMAX_API_KEY= +MINIMAX_BASE_URL= diff --git a/.gitignore b/.gitignore index 81d5216..c49893a 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,6 @@ supabase/.temp/ # IDE / local config .mcp.json -.env* + +# Docker / self-hosted Postgres +db_data/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..64450d4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +services: + db: + image: postgres:16-alpine + container_name: route_commerce_db + restart: unless-stopped + env_file: + - .env + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + volumes: + - db_data:/var/lib/postgresql/data + ports: + - "127.0.0.1:5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + interval: 5s + timeout: 5s + retries: 5 + start_period: 10s + +volumes: + db_data: + driver: local