Docker - #364
Conversation
WalkthroughThe change adds Docker and Compose support for local frontend, backend, and Redis development, including image definitions, startup scripts, configurable service URLs, persistent volumes, and Makefile helpers. It adds multi-platform GHCR publishing, weekly image retention cleanup, and pull request version validation workflows. Frontend version metadata is updated, network URL discovery is added, and README and Docker documentation describe setup, commands, architecture, and current Compose limitations. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 19
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f57daeaf-bbb1-4740-8638-945ebab0d00a
⛔ Files ignored due to path filters (1)
frontend/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (20)
.github/workflows/clean-up.yml.github/workflows/merge-protect.yml.github/workflows/publish-images.ymlMakefileREADME.mdbackend/.dockerignorebackend/Dockerfilebackend/Dockerfile .devbackend/api/settings.pybackend/start.shdocker-compose.ymldocs/docker.mdfrontend/.dockerignorefrontend/Dockerfilefrontend/Dockerfile.devfrontend/next.config.tsfrontend/package.jsonfrontend/src/lib/utils/api/server-fetch.tsfrontend/start.shscripts/print-ip.js
There was a problem hiding this comment.
Pull request overview
This PR introduces a Docker-based local development ecosystem (frontend, backend, Redis) plus supporting developer tooling (Make targets), CI workflows for publishing/retaining images, and documentation updates to standardize setup and improve reproducibility across contributors.
Changes:
- Adds Docker Compose stack and Dockerfiles for frontend/backend, plus
.dockerignorefiles to keep build contexts small. - Adds a
Makefileand helper scripts to simplify common Docker workflows (up/build/down/logs/shell/migrations). - Adds GitHub Actions workflows for image publishing, merge protection, and registry cleanup; updates docs/README for the new workflow.
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/print-ip.js | Adds a helper script to print network-accessible URLs for local dev. |
| README.md | Expands root documentation with Docker + Make-based quick start and project overview. |
| Makefile | Introduces Make targets wrapping Docker Compose workflows and URL printing. |
| frontend/start.sh | Adds a container entrypoint script for dev startup. |
| frontend/src/lib/utils/api/server-fetch.ts | Updates server-side API base URL selection to support Docker internal networking. |
| frontend/package.json | Bumps frontend version (used by release/branch/versioning workflows). |
| frontend/package-lock.json | Updates lockfile version fields to match the new package.json version. |
| frontend/next.config.ts | Adjusts dev rewrite destination to use INTERNAL_API_URL when present. |
| frontend/Dockerfile.dev | Adds a frontend development image build definition. |
| frontend/Dockerfile | Adds a multi-stage frontend production image using Next.js standalone output. |
| frontend/.dockerignore | Adds frontend Docker build context exclusions. |
| docs/docker.md | Adds detailed documentation of the Docker architecture, workflows, and known gaps. |
| docker-compose.yml | Defines the Compose stack (frontend/backend/redis), volumes, and Docker-network env wiring. |
| backend/start.sh | Adds a backend dev startup script (deps/migrations/uvicorn reload). |
| backend/Dockerfile .dev | Adds a backend dev Dockerfile (note: filename currently includes a space). |
| backend/Dockerfile | Adds a backend production Dockerfile (non-root user). |
| backend/api/settings.py | Makes Redis URLs configurable via environment variables for Docker compatibility. |
| backend/.dockerignore | Adds backend Docker build context exclusions. |
| .github/workflows/publish-images.yml | Adds CI workflow to build/push images to GHCR. |
| .github/workflows/merge-protect.yml | Adds merge gating + package-version-vs-branch-name enforcement for releases. |
| .github/workflows/clean-up.yml | Adds scheduled pruning of old container images in GHCR. |
Files not reviewed (1)
- frontend/package-lock.json: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| migrate: | ||
| docker compose exec backend python manage.py migrate |
There was a problem hiding this comment.
Is there any way to add arguments to this command? Such that I can specify a number, and it will run the migration with it as an argument.
For example, if I run make migrate 0027, it should run python manage.py migrate api 0027.
- This is used for unapplying migrations when switching to an older version.
| skip-tags: v*.*.* | ||
| dry-run: false | ||
|
|
||
| - name: Clean up Plancake Backend images | ||
| uses: snok/container-retention-policy@d3bdcf5ce9b05f685154e4a16c39233b245e3d53 # v3.1.0 | ||
| with: | ||
| account: plan-cake | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| image-names: plancake-backend | ||
| cut-off: 1w | ||
| timestamp-to-use: updated_at | ||
| keep-n-most-recent: 3 | ||
| skip-tags: v*.*.* |
There was a problem hiding this comment.
By specifying skip-tags to match all version branch containers, aren't they going to be kept forever? Or is that your intention?
In light of live updates and for other future development changes, docker might be better for maintaining easy reproducibility of our code. This PR set up a docker ecosystem for the project (frontend, backend, Redis), plus the Make commands, CI workflows, and docs needed to support it.
Docker Images
./backend/Dockerfile- production image (non-root user, Uvicorn)../frontend/Dockerfile- multi-stage production build using Next.js standalone output../backend/Dockerfile.dev- dev image, used by docker-compose./frontend/Dockerfile.dev- dev image (npm run dev), used by docker-compose.dockerignore- like.gitignoreDocker Compose
docker-compose.yml defines frontend, backend, and redis services, wired together over the Docker network, with bind mounts for hot-reloading and named volumes (redis_data, node_modules, next_cache) to avoid reinstalling/rebuilding on every restart.
Make Commands
Added a Makefile wrapping common workflows: up, build, down, restart, log streaming, container shells, and running/creating Django migrations. Run
make helpfor the full list. This was meant to make the developer experience a little smoother. Ideally, all you would need to remember are these make commands.CI/CD
publish-images.yml- builds and pushes both images to GHCR on pushes to main/version branches, multi-platform (amd64/arm64) with GHA build caching.clean-up.yml-weekly scheduled job to prune old images from the registry, keeping the most recent few.merge-protect.yml- gates PRs into main to version branches only, and checks that the branch name matches frontend/package.json's version.Docs
Updated the root
README.mdwith a proper Docker setup section (services overview, quick start, trimmed Make command table).Added
./docs/docker.mdwith a deeper explanation of the architecture, image build strategy, Compose file, CI workflows, and a "Known Gaps" section for follow-up work.