stack/docker/emulator/docker.compose.yaml
Konsti Wohlwend 3d4c608187
Customizable ports (#962)
<!--
ONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- RECURSEML_SUMMARY:START -->

## High-level PR Summary

This PR changes the default development ports for several background
services to avoid conflicts. PostgreSQL moves from port `5432` to
`8128`, Inbucket SMTP from `2500` to `8129`, Inbucket POP3 from `1100`
to `8130`, and the OpenTelemetry collector from `4318` to `8131`. All
references across configuration files, Docker Compose setups,
environment files, CI/CD workflows, test files, and documentation have
been updated to reflect these new port assignments. A knowledge base
document has been added to document the new port mappings.

⏱️ Estimated Review Time: 15-30 minutes

<details>
<summary>💡 Review Order Suggestion</summary>

| Order | File Path |
| --- | --- |
| 1 | `claude/CLAUDE-KNOWLEDGE.md` |
| 2 | `apps/dev-launchpad/public/index.html` |
| 3 | `docker/dependencies/docker.compose.yaml` |
| 4 | `docker/emulator/docker.compose.yaml` |
| 5 | `apps/backend/.env` |
| 6 | `apps/backend/.env.development` |
| 7 | `docker/server/.env.example` |
| 8 | `package.json` |
| 9 | `.devcontainer/devcontainer.json` |
| 10 | `apps/e2e/.env.development` |
| 11 | `.github/workflows/check-prisma-migrations.yaml` |
| 12 | `.github/workflows/docker-server-test.yaml` |
| 13 | `.github/workflows/e2e-api-tests.yaml` |
| 14 | `.github/workflows/e2e-source-of-truth-api-tests.yaml` |
| 15 | `.github/workflows/restart-dev-and-test.yaml` |
| 16 |
`apps/e2e/tests/backend/endpoints/api/v1/internal/email-drafts.test.ts`
|
| 17 | `apps/e2e/tests/backend/endpoints/api/v1/internal/email.test.ts`
|
| 18 | `apps/e2e/tests/backend/endpoints/api/v1/send-email.test.ts` |
| 19 |
`apps/e2e/tests/backend/endpoints/api/v1/unsubscribe-link.test.ts` |
| 20 | `apps/e2e/tests/backend/workflows.test.ts` |
| 21 | `docs/templates/others/self-host.mdx` |

</details>

[![Need help? Join our
Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U)

[![Analyze latest
changes](21c3d5c362/?repo_owner=stack-auth&repo_name=stack-auth&pr_number=962)

<!-- RECURSEML_SUMMARY:END -->

<!-- ELLIPSIS_HIDDEN -->


----

> [!IMPORTANT]
> This PR introduces customizable development ports using
`NEXT_PUBLIC_STACK_PORT_PREFIX`, updating configurations, documentation,
and tests accordingly.
> 
>   - **Behavior**:
> - Default development ports for services are now customizable via
`NEXT_PUBLIC_STACK_PORT_PREFIX`.
> - PostgreSQL port changed from `5432` to
`${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}28`.
> - Inbucket SMTP port changed from `2500` to
`${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}29`.
> - Inbucket POP3 port changed from `1100` to
`${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}30`.
> - OpenTelemetry collector port changed from `4318` to
`${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}31`.
>   - **Configuration**:
> - Updated `docker.compose.yaml` to use new port variables for services
like PostgreSQL, Inbucket, and OpenTelemetry.
> - Environment files in `apps/backend`, `apps/dashboard`, and
`apps/e2e` updated to use `NEXT_PUBLIC_STACK_PORT_PREFIX`.
> - `package.json` scripts updated to reflect new port configurations.
>   - **Documentation**:
>     - Added `CLAUDE-KNOWLEDGE.md` to document new port mappings.
>     - Updated `self-host.mdx` to reflect new port configurations.
>   - **Testing**:
> - Updated test files in `apps/e2e/tests` to use new port
configurations.
>     - Added `helpers/ports.ts` for port-related utilities in tests.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 76ef55f58f. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

----


<!-- ELLIPSIS_HIDDEN -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enable configurable development ports via a
NEXT_PUBLIC_STACK_PORT_PREFIX, allowing parallel local environments with
custom port prefixes.

- **Bug Fixes**
- Updated local service port mappings and CI/workflow settings so
tooling and tests use the new prefixed ports consistently.

- **Documentation**
- Added docs and contributor guidance for running multiple parallel
workspaces with custom port prefixes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: N2D4 <N2D4@users.noreply.github.com>
2025-10-20 15:24:47 -07:00

184 lines
5.4 KiB
YAML

# dashboard: 32101
# backend: 32102
# svix-server: 32201
# mock-oauth-server: 32202
# inbucket: 32203
# freestyle-mock: 32204
# s3mock: 32205
services:
# ================= Stack Auth Server =================
server:
build:
context: ../..
dockerfile: docker/server/Dockerfile
ports:
- 32101:8101
- 32102:8102
environment:
NEXT_PUBLIC_STACK_API_URL: "http://localhost:32102"
NEXT_PUBLIC_STACK_DASHBOARD_URL: "http://localhost:32101"
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@db:5432/stackframe"
STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@db:5432/stackframe"
STACK_SERVER_SECRET: "23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo"
STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST: "true"
STACK_RUN_MIGRATIONS: "true"
STACK_RUN_SEED_SCRIPT: "true"
STACK_EMULATOR_ENABLED: "true"
NEXT_PUBLIC_STACK_EMULATOR_ENABLED: "true"
STACK_EMULATOR_PROJECT_ID: "dff88d17-6d39-4b08-b4e2-c87c81f7218a"
NEXT_PUBLIC_STACK_EMULATOR_PROJECT_ID: "dff88d17-6d39-4b08-b4e2-c87c81f7218a"
NEXT_PUBLIC_STACK_SVIX_SERVER_URL: "http://localhost:32201"
STACK_SVIX_SERVER_URL: "http://svix-server:8071"
STACK_SVIX_API_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NTUxNDA2MzksImV4cCI6MTk3MDUwMDYzOSwibmJmIjoxNjU1MTQwNjM5LCJpc3MiOiJzdml4LXNlcnZlciIsInN1YiI6Im9yZ18yM3JiOFlkR3FNVDBxSXpwZ0d3ZFhmSGlyTXUifQ.En8w77ZJWbd0qrMlHHupHUB-4cx17RfzFykseg95SUk"
NEXT_PUBLIC_STACK_INBUCKET_WEB_URL: "http://localhost:32203"
STACK_EMAIL_HOST: "inbucket"
STACK_EMAIL_PORT: 2500
STACK_EMAIL_SECURE: "false"
STACK_EMAIL_USERNAME: "none"
STACK_EMAIL_PASSWORD: "none"
STACK_EMAIL_SENDER: "noreply@example.com"
STACK_FORWARD_MOCK_OAUTH_SERVER: "true"
STACK_OAUTH_MOCK_URL: "http://localhost:32202"
STACK_GITHUB_CLIENT_ID: "MOCK"
STACK_GITHUB_CLIENT_SECRET: "MOCK"
STACK_GOOGLE_CLIENT_ID: "MOCK"
STACK_GOOGLE_CLIENT_SECRET: "MOCK"
STACK_MICROSOFT_CLIENT_ID: "MOCK"
STACK_MICROSOFT_CLIENT_SECRET: "MOCK"
STACK_SPOTIFY_CLIENT_ID: "MOCK"
STACK_SPOTIFY_CLIENT_SECRET: "MOCK"
STACK_S3_ENDPOINT: "http://localhost:32205"
STACK_S3_BUCKET: "stack-storage"
STACK_S3_REGION: "us-east-1"
STACK_S3_ACCESS_KEY_ID: "S3RVER"
STACK_S3_SECRET_ACCESS_KEY: "S3RVER"
depends_on:
db:
condition: service_healthy
inbucket:
condition: service_started
svix-server:
condition: service_started
s3mock:
condition: service_healthy
freestyle-mock:
condition: service_started
# ================= Mock OAuth Server =================
mock-oauth-server:
build:
context: ../..
dockerfile: docker/mock-oauth-server/Dockerfile
ports:
- 32202:32202
# ================= PostgreSQL =================
db:
image: postgres:15
command: ["postgres", "-c"]
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: PASSWORD-PLACEHOLDER--uqfEC1hmmv
POSTGRES_DB: stackframe
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -p 5432 -d stackframe"]
interval: 5s
timeout: 10s
retries: 5
start_period: 10s
# ================= Inbucket =================
inbucket:
image: inbucket/inbucket:latest
environment:
INBUCKET_SMTP_ADDR: ":2500"
INBUCKET_POP3_ADDR: ":1100"
ports:
- 32203:9000
volumes:
- inbucket-data:/data
# ================= Svix =================
svix-db:
image: "docker.io/postgres:16.1"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: PASSWORD-PLACEHOLDER--KsoIMcchtp
POSTGRES_DB: svix
volumes:
- svix-postgres-data:/var/lib/postgresql/data
svix-redis:
image: docker.io/redis:7-alpine
command: --save 60 500 --appendonly yes --appendfsync everysec --requirepass PASSWORD-PLACEHOLDER--oVn8GSD6b9
volumes:
- svix-redis-data:/data
svix-server:
image: svix/svix-server
environment:
WAIT_FOR: 'true'
SVIX_REDIS_DSN: redis://:PASSWORD-PLACEHOLDER--oVn8GSD6b9@svix-redis:6379
SVIX_DB_DSN: postgres://postgres:PASSWORD-PLACEHOLDER--KsoIMcchtp@svix-db:5432/svix
SVIX_CACHE_TYPE: memory
SVIX_JWT_SECRET: secret
SVIX_LOG_LEVEL: trace
SVIX_QUEUE_TYPE: redis
ports:
- 32201:8071
depends_on:
- svix-redis
- svix-db
# ================= Adobe S3 Mock =================
s3mock:
image: adobe/s3mock:latest
ports:
- 32205:9090
environment:
- initialBuckets=stack-storage
- root=s3mockroot
- debug=false
volumes:
- s3mock-data:/tmp/s3mock
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/"]
interval: 30s
timeout: 10s
retries: 3
# ================= Freestyle mock =================
freestyle-mock:
build:
context: ../dependencies/freestyle-mock
dockerfile: Dockerfile
image: freestyle-mock
container_name: freestyle-mock
ports:
- "32204:8080"
environment:
DENO_DIR: /deno-cache
volumes:
- deno-cache:/deno-cache
# ================= volumes =================
volumes:
postgres-data:
inbucket-data:
svix-redis-data:
svix-postgres-data:
s3mock-data:
deno-cache: