Skip to content

chore: docker compose full-stack setup with migrate and crawler services#1

Open
Pacheco95 wants to merge 3 commits into
caiopizzol:mainfrom
Pacheco95:chore/compose-improvements
Open

chore: docker compose full-stack setup with migrate and crawler services#1
Pacheco95 wants to merge 3 commits into
caiopizzol:mainfrom
Pacheco95:chore/compose-improvements

Conversation

@Pacheco95
Copy link
Copy Markdown

Summary

  • Adds migrate and crawler services to docker-compose.yml so docker compose up --build is the only command needed to run the full stack
  • migrate applies the schema via drizzle-kit push before the crawler starts, using a separate Dockerfile.migrate that includes dev dependencies — keeping the production Dockerfile lean (--production install)
  • crawler restarts automatically by default; both the command and restart policy are configurable via CRAWLER_COMMAND and RESTART_POLICY env vars
  • Adds DB_PORT env var (default 5433) used in the postgres port mapping and drizzle.config.ts fallback
  • Moves inline comments in .env.example to their own lines to prevent values from being corrupted after cp .env.example .env

Test plan

  • cp .env.example .env && docker compose up --build — postgres becomes healthy, migrate applies schema and exits 0, crawler starts and begins fetching
  • CRAWLER_COMMAND="bun run crawl -- --year 2024" docker compose up — crawler runs with custom args
  • RESTART_POLICY=no docker compose up — crawler runs once and stops without restarting
  • DB_PORT=5434 docker compose up — postgres binds to host port 5434
  • Local dev path: docker compose up -d postgres && bun run db:push && bun run crawl still works

🤖 Generated with Claude Code

Pacheco95 and others added 3 commits May 12, 2026 10:06
The compose stack published postgres on 0.0.0.0:${DB_PORT} with a
hardcoded postgres/postgres default. On a host with a public IP, that
combination is discovered by internet-wide scanners within hours and is
a well-known target for credential-stuffing and the materialized-view
superuser-escalation chain.

- Bind the host port to 127.0.0.1 so the DB is reachable from the host
  only, not the network. The crawler still talks to postgres over the
  internal compose network on 5432.
- Require POSTGRES_PASSWORD via the :? operator so compose fails fast
  when it is unset, instead of silently falling back to a weak default.
- Drive POSTGRES_USER / POSTGRES_DB from env with safe defaults, and
  reuse POSTGRES_USER in the healthcheck.
- Document the new required var in .env.example with a generation hint
  and wire DATABASE_URL to interpolate it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant