Go - Failed due to unhealthy allocations

I have this site that’s been deployed successfully until v100++

Suddenly every deployment today failed with Failed due to unhealthy allocations

my fly.toml

# fly.toml file generated for risetku-apix on 2022-11-27T17:03:23+07:00

app = "risetku-apix"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  PORT = 8080

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "30s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

my dockerfile

FROM golang:1.19-alpine

LABEL version="1.0"

WORKDIR $GOPATH/src/github.com/febriliankr/risetku-api

COPY . .

RUN go mod tidy

RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/rest cmd/rest/*.go

EXPOSE 5000

ENTRYPOINT ["/go/bin/rest"]

my docker-compose.yml

version: "3.9"
services:
  api:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: risetku-api
    env_file:
      - .env
    ports:
      - 8080:5000
    network_mode: bridge
    restart: unless-stopped

I’m going insane, I’ve tried longering the grace period, changing the exposed 5000 to 8080, deploying to new instance, everything. fly vm status does not show anything meaningful, here it is:

Events
TIMESTAMP               TYPE            MESSAGE                      
2022-11-27T10:06:11Z    Received        Task received by client     
2022-11-27T10:06:11Z    Task Setup      Building Task Directory     
2022-11-27T10:11:11Z    Alloc Unhealthy Task not running by deadline

Please help, thanks

I don’t believe the EXPOSE parameter in the Dockerfile will end up mattering to Fly ( I’m happy to be corrected).

Is it correct to assume that the PORT env var is telling the Go program what port to listen on?

What’s the connection look like in the program? It should be something like “:8080” so it listens on all network interfaces (it needs to listen on ipv6, so a connection string like “0.0.0.0:8080” won’t work).

Otherwise it will be a matter of debugging what’s going wrong, perhaps by running the container locally and seeing what network it’s bound to, etc. (making sure the PORT env var is being read, etc).