Deploy with pnpm failed

Hello, i want to deploy express api from turborepo with pnpm. I have fly.toml and dockerfile inside root. After command flyctl deploy everythin works until relase and deployment.
I’ve got that message

→ v7 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v8

my dockerfile

FROM node:16-alpine AS base
ENV CI=true
ARG PNPM_VERSION=6.14.3
RUN npm --global install pnpm@${PNPM_VERSION}
WORKDIR /root/monorepo

FROM base AS dev
COPY ./pnpm-lock.yaml .
RUN pnpm fetch
COPY . .
RUN pnpm install --filter "@mono/server..." --frozen-lockfile --unsafe-perm
RUN pnpm build --filter "@mono/server^..."
RUN pnpm test --if-present --filter "@mono/server"
RUN pnpm build --filter "@mono/server"

WORKDIR /root/monorepo/apps/server
EXPOSE 3002
ENV NODE_ENV=production
#ENTRYPOINT ["pnpm", "build:start"]

fly.toml

# fly.toml file generated for routines-api on 2023-02-14T07:53:22+01:00

app = "routines-api"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
  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 = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

logs

app[749c8ae7] waw [info] Starting clean up.

2023-02-15T06:43:44.992 runner[749c8ae7] waw [info] Starting instance

2023-02-15T06:43:45.068 runner[749c8ae7] waw [info] Configuring virtual machine

2023-02-15T06:43:45.069 runner[749c8ae7] waw [info] Pulling container image

2023-02-15T06:43:45.613 runner[749c8ae7] waw [info] Unpacking image

2023-02-15T06:43:45.621 runner[749c8ae7] waw [info] Preparing kernel init

2023-02-15T06:43:45.952 runner[749c8ae7] waw [info] Configuring firecracker

2023-02-15T06:43:46.271 runner[749c8ae7] waw [info] Starting virtual machine

2023-02-15T06:43:46.469 app[749c8ae7] waw [info] Starting init (commit: cf3bf32)...

2023-02-15T06:43:46.576 app[749c8ae7] waw [info] Preparing to run: `docker-entrypoint.sh node` as root

2023-02-15T06:43:46.643 app[749c8ae7] waw [info] 2023/02/15 06:43:46 listening on [fdaa:1:4efd:a7b:84:749c:8ae7:2]:22 (DNS: [fdaa::3]:53)

2023-02-15T06:43:47.638 app[749c8ae7] waw [info] Starting clean up.

2023-02-15T06:43:54.657 runner[749c8ae7] waw [info] Starting instance

2023-02-15T06:43:54.731 runner[749c8ae7] waw [info] Configuring virtual machine

2023-02-15T06:43:54.733 runner[749c8ae7] waw [info] Pulling container image

2023-02-15T06:43:55.554 runner[749c8ae7] waw [info] Unpacking image

2023-02-15T06:43:55.562 runner[749c8ae7] waw [info] Preparing kernel init

2023-02-15T06:43:55.891 runner[749c8ae7] waw [info] Configuring firecracker

2023-02-15T06:43:56.010 runner[749c8ae7] waw [info] Starting virtual machine

2023-02-15T06:43:56.218 app[749c8ae7] waw [info] Starting init (commit: cf3bf32)...

2023-02-15T06:43:56.244 app[749c8ae7] waw [info] Preparing to run: `docker-entrypoint.sh node` as root

2023-02-15T06:43:56.267 app[749c8ae7] waw [info] 2023/02/15 06:43:56 listening on [fdaa:1:4efd:a7b:84:749c:8ae7:2]:22 (DNS: [fdaa::3]:53)

2023-02-15T06:43:57.261 app[749c8ae7] waw [info] Starting clean up.

Hey there!

The reason you’re seeing these unhealthy allocations is because on deploy, Fly.io spins up the container and checks if traffic is allowed on the ports that are defined in the [[services.ports]].

I suspect that your internal_port is not correct: In your Dockerfile you are exposing port 3002 of your container, but in the [[services]] internal_port you are routing traffic to port 8080. I bet that if you change internal_port to 3002 the health checks will succeed.

Here’s (in short) how the services in your fly.toml work:

  • in the [[services.ports]] you define what ports are going to be open to the outside world, in your case these are port 80 and 443. The handlers define the supported protocols, so port 80 supports http and port 443 supports both http and tls (https).

  • These outside ports will be linked to a port on your container. This is defined by the internal_port under the [[services]] section. The way it’s set up now, traffic coming form outside on ports 80 or 443 will be routed to port 8080 on your container.

You can find more info about services sections here: App Configuration (fly.toml) · Fly Docs

So, after i changed port i went a bit further, and i see that container is running, but after a couple of seconds i got an error

2023-02-15T15:36:18.446 runner[5b362590] waw [info] Starting instance

2023-02-15T15:36:18.519 runner[5b362590] waw [info] Configuring virtual machine

2023-02-15T15:36:18.521 runner[5b362590] waw [info] Pulling container image

2023-02-15T15:36:21.727 runner[5b362590] waw [info] Unpacking image

2023-02-15T15:36:22.952 runner[5b362590] waw [info] Preparing kernel init

2023-02-15T15:36:23.284 runner[5b362590] waw [info] Configuring firecracker

2023-02-15T15:36:23.398 runner[5b362590] waw [info] Starting virtual machine

2023-02-15T15:36:23.682 app[5b362590] waw [info] Starting init (commit: cf3bf32)...

2023-02-15T15:36:23.708 app[5b362590] waw [info] Preparing to run: `docker-entrypoint.sh node` as root

2023-02-15T15:36:23.735 app[5b362590] waw [info] 2023/02/15 15:36:23 listening on [fdaa:1:4efd:a7b:84:5b36:2590:2]:22 (DNS: [fdaa::3]:53)

2023-02-15T15:36:24.724 app[5b362590] waw [info] Starting clean up.

2023-02-15T15:36:29.744 runner[5b362590] waw [info] Starting instance

2023-02-15T15:36:29.821 runner[5b362590] waw [info] Configuring virtual machine

2023-02-15T15:36:29.823 runner[5b362590] waw [info] Pulling container image

2023-02-15T15:36:30.332 runner[5b362590] waw [info] Unpacking image

2023-02-15T15:36:30.345 runner[5b362590] waw [info] Preparing kernel init

2023-02-15T15:36:30.656 runner[5b362590] waw [info] Configuring firecracker

2023-02-15T15:36:30.771 runner[5b362590] waw [info] Starting virtual machine

2023-02-15T15:36:30.964 app[5b362590] waw [info] Starting init (commit: cf3bf32)...

2023-02-15T15:36:30.990 app[5b362590] waw [info] Preparing to run: `docker-entrypoint.sh node` as root

2023-02-15T15:36:31.012 app[5b362590] waw [info] 2023/02/15 15:36:31 listening on [fdaa:1:4efd:a7b:84:5b36:2590:2]:22 (DNS: [fdaa::3]:53)

2023-02-15T15:36:32.009 app[5b362590] waw [info] Starting clean up.

2023-02-15T15:36:39.017 runner[5b362590] waw [info] Starting instance

2023-02-15T15:36:39.096 runner[5b362590] waw [info] Configuring virtual machine

2023-02-15T15:36:39.097 runner[5b362590] waw [info] Pulling container image

2023-02-15T15:36:39.615 runner[5b362590] waw [info] Unpacking image

2023-02-15T15:36:39.628 runner[5b362590] waw [info] Preparing kernel init

2023-02-15T15:36:39.932 runner[5b362590] waw [info] Configuring firecracker

2023-02-15T15:36:40.056 runner[5b362590] waw [info] Starting virtual machine

2023-02-15T15:36:40.254 app[5b362590] waw [info] Starting init (commit: cf3bf32)...

2023-02-15T15:36:40.283 app[5b362590] waw [info] Preparing to run: `docker-entrypoint.sh node` as root

2023-02-15T15:36:40.304 app[5b362590] waw [info] 2023/02/15 15:36:40 listening on [fdaa:1:4efd:a7b:84:5b36:2590:2]:22 (DNS: [fdaa::3]:53)

2023-02-15T15:36:41.299 app[5b362590] waw [info] Starting clean up.