Skip to content

Add a Dockerfile and docker-compose for the API, worker, Postgres, and NATS for local/prod parity #57

Description

@Jagadeeshftw

📌 Description

The repo deploys via railway.json/.railwayignore and documents Postgres via DOCKER_POSTGRES_SETUP.md, but there is no Dockerfile for the Go service and no docker-compose.yml wiring the API, the worker (cmd/worker), Postgres, and NATS together. Local setup and CI/prod parity rely on ad-hoc steps and make dev (air).

💡 Why it matters: A multi-stage Dockerfile and compose file give reproducible local environments and a clear deployable artifact, reducing "works on my machine" issues.

🧩 Requirements and context

  • Add a multi-stage Dockerfile building cmd/api (and a build arg/target for cmd/worker) on the Go 1.24 toolchain, producing a small static image.
  • Add docker-compose.yml with services for api, worker, postgres (with a volume), and nats, wired by env.
  • Use .env.example as the basis for compose env; ensure /ready is used as a healthcheck.
  • Document docker compose up in DEVELOPMENT.md and QUICK_START.md.
  • Keep image non-root and minimal.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b devops/dockerfile-and-compose

2. Implement changes

  • Write/modify the relevant source: Dockerfile, docker-compose.yml, .dockerignore
  • Write comprehensive tests: a CI job that builds the image and runs compose up smoke check (optional)
  • Add documentation: DEVELOPMENT.md, QUICK_START.md
  • Include comments in the Dockerfile explaining stages
  • Validate security assumptions: run as non-root, no secrets baked into the image

3. Test and commit

  • Run tests:
docker build -t grainlify-api . && docker compose config
  • Cover edge cases: worker target builds; healthcheck hits /ready
  • Include build output and security notes in the PR description.

Example commit message

devops: add multi-stage Dockerfile and docker-compose

✅ Acceptance criteria

  • Multi-stage Dockerfile builds api and worker
  • docker-compose wires api, worker, postgres, nats
  • Healthcheck uses /ready
  • Local usage documented; image runs as non-root

🔒 Security notes

Do not bake secrets or .env into the image; ensure the final stage is non-root and contains no build toolchain.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuedevopsdocumentationImprovements or additions to documentation

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions