Skip to content

Let docker-compose.dev.yml scale rest-api past one container #236

Description

@HMarzban

Problem

docker compose -f docker-compose.dev.yml up --scale rest-api=2 cannot run. The rest-api service sets a fixed container_name and binds a fixed host port 4000:4000. A container name must be unique, and a host port cannot bind twice.

This matters because production runs rest-api with replicas: 2 and no sticky session, so any state held per process is invisible in development and breaks in production.

What to do

Remove container_name from the rest-api service, and change the fixed port binding so more than one replica can start. A port range, or dropping the host binding and reaching the service through the network, both work.

Leave the other services alone.

Acceptance

  • docker compose -f docker-compose.dev.yml up --scale rest-api=2 starts two containers.
  • The single-container path still works unchanged for everyday development.

Notes

There is a cheaper workaround for the specific case that found this: two processes on two ports, APP_PORT=4001 bun src/index.ts and APP_PORT=4002 bun src/index.ts. Two processes are two memories, which is the production condition. #226 uses that workaround for its stateless test.

So this issue is only worth doing if someone needs real container scaling in development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions