stack/docker/dependencies/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

254 lines
7.3 KiB
YAML

services:
# ================= PostgreSQL =================
db:
build: ../postgres-with-extensions
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: PASSWORD-PLACEHOLDER--uqfEC1hmmv
POSTGRES_DB: stackframe
POSTGRES_DELAY_MS: ${POSTGRES_DELAY_MS:-0}
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}28:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
cap_add:
- NET_ADMIN # required for the fake latency during dev
# ================= PgHero =================
pghero:
image: ankane/pghero:latest
environment:
DATABASE_URL: postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@db:5432/stackframe
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}16:8080"
# ================= PgAdmin =================
pgadmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: PASSWORD-PLACEHOLDER--vu9p2iy3f
PGADMIN_CONFIG_SERVER_MODE: "False"
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False"
configs:
- source: pgadmin_servers
target: /pgadmin4/servers.json
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}17:80"
# ================= Supabase Studio =================
supabase-studio:
image: supabase/studio:20241202-71e5240
restart: unless-stopped
healthcheck:
test:
[
"CMD",
"node",
"-e",
"fetch('http://studio:3000/api/profile').then((r) => {if (r.status !== 200) throw new Error(r.status)})"
]
timeout: 10s
interval: 5s
retries: 3
environment:
STUDIO_PG_META_URL: http://supabase-meta:8080
POSTGRES_PASSWORD: PASSWORD-PLACEHOLDER--uqfEC1hmmv
OPENAI_API_KEY: ${OPENAI_API_KEY:-}
NEXT_PUBLIC_ENABLE_LOGS: true
NEXT_ANALYTICS_BACKEND_PROVIDER: postgres
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}18:3000"
supabase-meta:
image: supabase/postgres-meta:v0.84.2
restart: unless-stopped
environment:
PG_META_PORT: 8080
PG_META_DB_HOST: db
PG_META_DB_PORT: 8128
PG_META_DB_NAME: stackframe
PG_META_DB_USER: postgres
PG_META_DB_PASSWORD: PASSWORD-PLACEHOLDER--uqfEC1hmmv
# ================= Inbucket =================
inbucket:
image: inbucket/inbucket:3.1.0
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}29:2500"
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}05:9000"
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}30:1100"
volumes:
- inbucket-data:/data
# ================= OpenTelemetry & Jaeger =================
jaeger:
image: jaegertracing/all-in-one:latest
environment:
- COLLECTOR_OTLP_ENABLED=true
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}07:16686" # Jaeger UI
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}31:4318" # OTLP Endpoint
restart: always
# ================= 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:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}13:8071"
depends_on:
- svix-redis
- svix-db
# ================= Adobe S3 Mock =================
s3mock:
image: adobe/s3mock:latest
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}21: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
# ================= LocalStack =================
localstack:
image: localstack/localstack:4.7
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}24:4566" # LocalStack Gateway
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}50-${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}99:4510-4559" # external services port range
environment:
# LocalStack configuration: https://docs.localstack.cloud/references/configuration/
- DEBUG=${DEBUG:-0}
volumes:
- localstack-data:/var/lib/localstack
- "/var/run/docker.sock:/var/run/docker.sock"
# ================= Freestyle mock =================
freestyle-mock:
build:
context: ./freestyle-mock
dockerfile: Dockerfile
image: freestyle-mock
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}22:8080" # POST http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}19/execute/v1/script
extra_hosts:
- "host.docker.internal:host-gateway" # noop on Docker Desktop/Orbstack, enables host.docker.internal on Linux
environment:
DENO_DIR: /deno-cache
HOST_ON_HOST: host.docker.internal
volumes:
- deno-cache:/deno-cache
# ================= Stripe =================
stripe-mock:
image: stripe/stripe-mock:v0.195.0
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}23:12111"
environment:
- STRIPE_API_KEY=sk_test_1234567890
# ================= QStash =================
qstash:
image: public.ecr.aws/upstash/qstash:latest
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}25:8080"
command: qstash dev
extra_hosts:
- "host.docker.internal:host-gateway" # noop on Docker Desktop/Orbstack, enables host.docker.internal on Linux
environment:
HOST_ON_HOST: host.docker.internal
# ================= MCPJam Inspector =================
mcpjam-inspector:
image: node:20-alpine
ports:
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}26:3001"
command: >
sh -c "echo '{\"mcpServers\":{\"local-stack-auth-docs\":{\"url\":\"http://host.docker.internal:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}04/api/internal/mcp\"}}}' > /app/mcp.json && npx -y @mcpjam/inspector@latest --port 3001 --config /app/mcp.json"
working_dir: /app
volumes:
- mcpjam-inspector-data:/root
extra_hosts:
- "host.docker.internal:host-gateway" # noop on Docker Desktop/Orbstack, enables host.docker.internal on Linux
environment:
HOST_ON_HOST: host.docker.internal
# ================= volumes =================
volumes:
postgres-data:
inbucket-data:
svix-redis-data:
svix-postgres-data:
s3mock-data:
deno-cache:
localstack-data:
mcpjam-inspector-data:
# ================= configs =================
configs:
pgadmin_servers:
content: |
{
"Servers": {
"1": {
"Name": "Local Postgres DB",
"Group": "Servers",
"Host": "db",
"Port": 5432,
"Username": "postgres",
"PasswordExecCommand": "echo 'PASSWORD-PLACEHOLDER--uqfEC1hmmv'",
"MaintenanceDB": "stackframe"
}
}
}