Skip to content

Docker healthcheck uses hardcoded port instead of API_PORT #153

@luandro

Description

@luandro

Description

The healthcheck in docker-compose.yml always calls localhost:3001:

healthcheck:
  test:
    [
      "CMD",
      "bun",
      "--silent",
      "-e",
      "fetch('http://localhost:3001/health').then(r => process.exit(r.ok ? 0 : 1))",
    ]

Deployments that set API_PORT to a different value will be marked unhealthy even when running correctly.

Impact

  • Containers with non-default API_PORT will fail health checks
  • Kubernetes/Docker orchestration may repeatedly restart healthy containers
  • False negative health status in production deployments

Recommendation

Update the healthcheck to dynamically use the API_PORT environment variable:

healthcheck:
  test:
    [
      "CMD",
      "bun",
      "--silent",
      "-e",
      "fetch(\`http://localhost:\${process.env.API_PORT || 3001}/health\`).then(r => process.exit(r.ok ? 0 : 1))",
    ]

Priority

Medium - affects deployment reliability but only when using non-default ports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions