-
Notifications
You must be signed in to change notification settings - Fork 6
Add Docker Compose configuration for API and platform services #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2722de2
085162b
d4d3eb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,12 @@ This guide covers everything you need to run any part of the Call of Code platfo | |
|
|
||
| ## Overview | ||
|
|
||
| The repository ships with **four Docker Compose configurations**: | ||
| The repository ships with **five Docker Compose configurations**: | ||
|
|
||
| | File | Purpose | Services | | ||
| |------|---------|----------| | ||
| | `docker-compose.yml` | **API-only** dev (standalone) | `coc-api` | | ||
| | `docker/docker-compose.yml` | **All platforms** master stack | all 6 services | | ||
| | `docker/coc-member/docker-compose.yml` | Full **COC Member** stack | `coc-api` + `server` + `web` | | ||
| | `docker/coc-admin/docker-compose.yml` | Full **COC Admin** stack | `coc-api` + `server` + `web` | | ||
| | `docker/callofcode.in/docker-compose.yml` | Full **callofcode.in** website stack | `coc-api` + `frontend` | | ||
|
|
@@ -76,6 +77,35 @@ cp docker/callofcode.in/.env.local.frontend.example docker/callofcode.in/.env.lo | |
|
|
||
| ## Running the Stacks | ||
|
|
||
| ### All platforms together (master stack) | ||
|
|
||
| Use this when you need all three platforms running simultaneously (e.g. testing cross-platform API behaviour or running the full suite locally): | ||
|
|
||
| ```bash | ||
| # From the repo root — watch mode recommended | ||
| docker compose -f docker/docker-compose.yml up --watch | ||
|
|
||
| # Or standard mode | ||
| docker compose -f docker/docker-compose.yml up --build | ||
| ``` | ||
|
|
||
| All six services share a single `coc-network` bridge and a single `coc-api` instance: | ||
|
|
||
| | Service | Container | Host port | Override env var | | ||
| |---------|-----------|-----------|------------------| | ||
| | `coc-api` | `3000` | **3000** | `COC_API_PORT` | | ||
| | `callofcode-frontend` | `3001` | **3001** | `CALLOFCODE_PORT` | | ||
| | `coc-admin-server` | `8000` | **8001** | `COC_ADMIN_BACKEND_PORT` | | ||
| | `coc-admin-web` | `5173` | **5174** | `COC_ADMIN_FRONTEND_PORT` | | ||
| | `coc-member-server` | `8000` | **8002** | `COC_MEMBER_BACKEND_PORT` | | ||
| | `coc-member-web` | `5173` | **5175** | `COC_MEMBER_FRONTEND_PORT` | | ||
|
|
||
| > **Port remapping**: because `coc-admin` and `coc-member` both internally bind `8000` and `5173`, the master stack remaps them to unique host ports to avoid conflicts. Internal service-to-service communication (`API_URL=http://coc-api:3000`) still uses the original container ports. | ||
|
|
||
| > **Env files required**: make sure all six env files exist before starting (see [Environment Setup](#environment-setup) above). | ||
|
|
||
| --- | ||
|
|
||
| ### API-only (standalone development) | ||
|
|
||
| Use this when you're only working on the `coc-api` itself: | ||
|
|
@@ -217,10 +247,14 @@ The dev compose files use `target: builder` so that devDependencies and the Pris | |
| The `dockerfile:` path in compose is relative to the `context`, not the compose file. Our configs set `context: ../..` (repo root) so `dockerfile: Dockerfile` resolves correctly. | ||
|
|
||
| **Port already in use** | ||
| Set a custom port via the `PORT` env variable before running: | ||
| For the individual stacks, set a custom port via the `PORT` env variable: | ||
| ```bash | ||
| PORT=3001 docker compose up | ||
| ``` | ||
| For the master stack, override the specific service port: | ||
| ```bash | ||
| COC_API_PORT=3010 COC_ADMIN_BACKEND_PORT=8010 docker compose -f docker/docker-compose.yml up | ||
| ``` | ||
|
Comment on lines
+250
to
+257
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor Scope the port override example to the compose file being used. 🤖 Prompt for AI Agents |
||
|
|
||
| **Prisma migration errors on startup** | ||
| The `coc-api` container runs `prisma migrate deploy` on every start. If the DB is unreachable, the container will exit. Verify your `DATABASE_URL` and `DIRECT_URL` in `.env.local`. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| # ============================================================================= | ||
| # Master Docker Compose — All Platforms | ||
| # Runs coc-api + all three frontends/backends together on a single network. | ||
| # | ||
| # Usage: | ||
| # docker compose -f docker/docker-compose.yml up --watch | ||
| # | ||
| # Port map: | ||
| # 3000 → coc-api (shared API) | ||
| # 3001 → callofcode.in (frontend) | ||
| # 8001 → coc-admin backend | ||
| # 5174 → coc-admin frontend | ||
| # 8002 → coc-member backend | ||
| # 5175 → coc-member frontend | ||
| # ============================================================================= | ||
|
|
||
| name: coc-all | ||
|
|
||
| services: | ||
|
|
||
| coc-api: | ||
| image: coc-api | ||
| build: | ||
| context: .. | ||
| dockerfile: Dockerfile | ||
| target: builder # builder stage has devDeps + bun --watch | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${COC_API_PORT:-3000}:3000" | ||
| env_file: | ||
| - ../.env.local # Local dev env vars (Supabase connection strings, etc.) | ||
| environment: | ||
| NODE_ENV: development | ||
| volumes: | ||
| - ../:/app | ||
| - /app/node_modules | ||
| - /app/node_modules/.prisma | ||
| command: > | ||
| sh -c "bunx prisma generate && | ||
| bunx prisma migrate deploy && | ||
| bun --watch src/server.ts" | ||
| develop: | ||
| watch: | ||
| - path: ../src | ||
| action: sync | ||
| target: /app/src | ||
| - path: ../package.json | ||
| action: rebuild | ||
| - path: ../bun.lock | ||
| action: rebuild | ||
| - path: ../prisma | ||
| action: rebuild | ||
| healthcheck: | ||
| test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"] | ||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 15s | ||
| networks: | ||
| - coc-network | ||
|
|
||
| # callofcode.in — main website frontend | ||
|
|
||
| callofcode-frontend: | ||
| image: callofcode07/callofcode:latest | ||
| pull_policy: missing | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${CALLOFCODE_PORT:-3001}:3001" | ||
| env_file: | ||
| - callofcode.in/.env.local.frontend | ||
|
Comment on lines
+70
to
+71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check whether the referenced env files exist relative to docker/
for f in \
docker/callofcode.in/.env.local.frontend \
docker/coc-admin/.env.local.backend \
docker/coc-admin/.env.local.frontend \
docker/coc-member/.env.local.backend \
docker/coc-member/.env.local.frontend \
.env.local ; do
if [ -e "$f" ]; then echo "FOUND: $f"; else echo "MISSING: $f"; fi
done
# Also surface any similarly named env files anywhere in the repo
fd -H -t f '.env.local'Repository: call-0f-code/COC-API Length of output: 641 🏁 Script executed: #!/bin/bash
set -e
git ls-files docker/docker-compose.yml docker/callofcode.in/.env.local.frontend.example docker/coc-admin/.env.local.backend.example docker/coc-admin/.env.local.frontend.example docker/coc-member/.env.local.backend.example docker/coc-member/.env.local.frontend.example
printf '\n--- docker-compose excerpts ---\n'
sed -n '60,180p' docker/docker-compose.yml
printf '\n--- all env_file refs ---\n'
rg -n "env_file:|- \.env|\.env\.local" docker/docker-compose.yml docker -g '!**/.git/**'Repository: call-0f-code/COC-API Length of output: 6780 🏁 Script executed: #!/bin/bash
set -e
git ls-files docker/docker-compose.yml docker/callofcode.in/.env.local.frontend.example docker/coc-admin/.env.local.backend.example docker/coc-admin/.env.local.frontend.example docker/coc-member/.env.local.backend.example docker/coc-member/.env.local.frontend.example
printf '\n--- docker-compose excerpts ---\n'
sed -n '60,180p' docker/docker-compose.yml
printf '\n--- all env_file refs ---\n'
rg -n "env_file:|- \.env|\.env\.local" docker/docker-compose.yml docker -g '!**/.git/**'Repository: call-0f-code/COC-API Length of output: 6780 🏁 Script executed: #!/bin/bash
set -e
git ls-files docker/docker-compose.yml docker/callofcode.in/.env.local.frontend.example docker/coc-admin/.env.local.backend.example docker/coc-admin/.env.local.frontend.example docker/coc-member/.env.local.backend.example docker/coc-member/.env.local.frontend.example
printf '\n--- docker-compose excerpts ---\n'
sed -n '60,180p' docker/docker-compose.yml
printf '\n--- all env_file refs ---\n'
rg -n "env_file:|- \.env|\.env\.local" docker/docker-compose.yml docker -g '!**/.git/**'Repository: call-0f-code/COC-API Length of output: 6780 Add the missing 🤖 Prompt for AI Agents
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. us bro us
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since those
That way new contributors joining the team won't be left wondering why ʕ •ᴥ•ʔ |
||
| environment: | ||
| - NODE_ENV=development | ||
| - API_BASE_URL=http://coc-api:3000 | ||
| depends_on: | ||
| coc-api: | ||
| condition: service_healthy | ||
| networks: | ||
| - coc-network | ||
| command: ["npm", "run", "dev"] | ||
|
|
||
| # coc-admin — admin backend | ||
|
|
||
| coc-admin-server: | ||
| image: callofcode07/coc-admin-backend:latest | ||
| pull_policy: missing | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${COC_ADMIN_BACKEND_PORT:-8001}:8000" # remapped to 8001 to avoid conflict | ||
| env_file: | ||
| - coc-admin/.env.local.backend | ||
| environment: | ||
| - PORT=8000 | ||
| - API_URL=http://coc-api:3000 | ||
| - ALLOWED_ORIGINS=http://localhost:${COC_ADMIN_FRONTEND_PORT:-5174} | ||
| depends_on: | ||
| coc-api: | ||
| condition: service_healthy | ||
| healthcheck: | ||
| test: ["CMD", "wget", "-qO-", "http://localhost:8000/health"] | ||
| interval: 30s | ||
| timeout: 3s | ||
| retries: 3 | ||
| start_period: 10s | ||
| networks: | ||
| - coc-network | ||
|
|
||
| # coc-admin — admin frontend | ||
| coc-admin-web: | ||
| image: callofcode07/coc-admin-frontend:latest | ||
| pull_policy: missing | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${COC_ADMIN_FRONTEND_PORT:-5174}:5173" # remapped to 5174 to avoid conflict | ||
| env_file: | ||
| - coc-admin/.env.local.frontend | ||
| environment: | ||
| - VITE_API_URL=http://localhost:8001 | ||
| depends_on: | ||
| coc-admin-server: | ||
| condition: service_healthy | ||
| networks: | ||
| - coc-network | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # coc-member — member backend | ||
| # --------------------------------------------------------------------------- | ||
| coc-member-server: | ||
| image: callofcode07/coc-member-backend:latest | ||
| pull_policy: missing | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${COC_MEMBER_BACKEND_PORT:-8002}:8000" # remapped to 8002 to avoid conflict | ||
| env_file: | ||
| - coc-member/.env.local.backend | ||
| environment: | ||
| - PORT=8000 | ||
| - API_URL=http://coc-api:3000 | ||
| - ALLOWED_ORIGINS=http://localhost:${COC_MEMBER_FRONTEND_PORT:-5175} | ||
| depends_on: | ||
| coc-api: | ||
| condition: service_healthy | ||
| healthcheck: | ||
| test: ["CMD", "wget", "-qO-", "http://localhost:8000/health"] | ||
| interval: 30s | ||
| timeout: 3s | ||
| retries: 3 | ||
| start_period: 10s | ||
| networks: | ||
| - coc-network | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # coc-member — member frontend | ||
| # --------------------------------------------------------------------------- | ||
| coc-member-web: | ||
| image: callofcode07/coc-member-frontend:latest | ||
| pull_policy: missing | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${COC_MEMBER_FRONTEND_PORT:-5175}:5173" # remapped to 5175 to avoid conflict | ||
| env_file: | ||
| - coc-member/.env.local.frontend | ||
| environment: | ||
| - VITE_API_URL=http://localhost:8002 | ||
| depends_on: | ||
| coc-member-server: | ||
| condition: service_healthy | ||
| networks: | ||
| - coc-network | ||
|
|
||
| networks: | ||
| coc-network: | ||
| driver: bridge | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the blank line inside this blockquote.
That empty quoted line trips MD028 and will keep markdownlint failing.
🛠️ Suggested fix
> **Port remapping**: because `coc-admin` and `coc-member` both internally bind `8000` and `5173`, the master stack remaps them to unique host ports to avoid conflicts. Internal service-to-service communication (`API_URL=http://coc-api:3000`) still uses the original container ports. -> > **Env files required**: make sure all six env files exist before starting (see [Environment Setup](`#environment-setup`) above).📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 104-104: Blank line inside blockquote
(MD028, no-blanks-blockquote)
🤖 Prompt for AI Agents
Source: Linters/SAST tools