Add Docker setup: one script to set up/start/stop the full stack
A new developer needs only Docker Desktop — no local Go, Node, or PostgreSQL. - docker-compose.yml: PostgreSQL + Go API + Angular (nginx) with healthcheck, migrations auto-applied via docker-entrypoint-initdb.d, data in a volume - backend/Dockerfile: static Go binary on distroless (nonroot) - frontend/Dockerfile: Angular prod build served by nginx, which proxies /api to the api service (same origin, no CORS) - docker.ps1: setup / start / stop / restart / reset / rebuild / status / logs; reads DB creds from backend/.env (single source, nothing duplicated) - .dockerignore keeps .env and local artifacts out of image build contexts - README: "Run with Docker" quick start Not yet run end to end here (Docker is not installed on this machine); the compose and script are validated for syntax and structure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
17a7e8ffd5
commit
a9dc273e09
@@ -0,0 +1,57 @@
|
||||
# TravelHub full stack on Docker. Drive it with docker.ps1 (which supplies the
|
||||
# DB_* values from backend/.env), or run docker compose directly after exporting
|
||||
# DB_USER / DB_PASSWORD / DB_NAME yourself.
|
||||
#
|
||||
# PostgreSQL internal only (data in the pgdata volume)
|
||||
# api Go API -> http://localhost:8080
|
||||
# web Angular via nginx -> http://localhost:4200 (proxies /api to api)
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17
|
||||
environment:
|
||||
POSTGRES_USER: ${DB_USER:-postgres}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:?set DB_PASSWORD (docker.ps1 reads it from backend/.env)}
|
||||
POSTGRES_DB: ${DB_NAME:-travelhub}
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
# Migrations run once, on first creation of an empty data directory, in
|
||||
# order (001_init, 002_seed, 003_demo_bookings). The seed generates
|
||||
# flights relative to now(), so a fresh volume always has future-dated
|
||||
# inventory. `docker.ps1 reset` wipes the volume to re-seed.
|
||||
- ./backend/migrations:/docker-entrypoint-initdb.d:ro
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-travelhub}']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
restart: unless-stopped
|
||||
|
||||
api:
|
||||
build: ./backend
|
||||
environment:
|
||||
DB_HOST: postgres
|
||||
DB_PORT: '5432'
|
||||
DB_USER: ${DB_USER:-postgres}
|
||||
DB_PASSWORD: ${DB_PASSWORD}
|
||||
DB_NAME: ${DB_NAME:-travelhub}
|
||||
DB_SSLMODE: disable
|
||||
PORT: '8080'
|
||||
CORS_ORIGINS: http://localhost:4200
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- '8080:8080'
|
||||
restart: unless-stopped
|
||||
|
||||
web:
|
||||
build: ./frontend
|
||||
depends_on:
|
||||
- api
|
||||
ports:
|
||||
- '4200:80'
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
Reference in New Issue
Block a user