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"]
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.