NextJs deploy on

Hi ,

I am trying to deploy a simple NextJs application on via below Dockerfile.

# Install dependencies only when needed
FROM node:14-alpine AS deps
# Check to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:14-alpine AS builder
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn build

# Production image, copy all the files and run next
FROM node:14-alpine AS runner

ENV NODE_ENV production

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001

# You only need to copy next.config.js if you are NOT using the default configuration
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

USER nextjs


# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here:
# Uncomment the following line in case you want to disable telemetry.

CMD ["yarn", "start"]

But getting an error
Error error building: failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile line greater than max allowed size of 65535

So to avoid this problem I manually did docker build -t

That worked and image got created. But when trying to deploy the image using below command
flyctl deploy --image <some-name>


# fly.toml file generated for muddy-pond-7350 on 2021-08-12T09:52:52+05:30
app = "muddy-pond-7350"

kill_signal = "SIGINT"
kill_timeout = 5

  PORT = "3000"

  allowed_public_ports = []
  auto_rollback = true

  http_checks = []
  internal_port = 3000
  protocol = "tcp"
  script_checks = []

    hard_limit = 25
    soft_limit = 20
    type = "connections"

    handlers = ["http"]
    port = 80

    handlers = ["tls", "http"]
    port = 443

    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

It is failing with below error

==> Creating release
Release v1 created

You can detach the terminal anytime without stopping the deployment
Monitoring Deployment

1 desired, 1 placed, 0 healthy, 1 unhealthy
v1 failed - Failed due to unhealthy allocations - no stable job version to auto revert to
***v1 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v2

Troubleshooting guide at

Also as mentioned in trouble shooting guide I am not getting the port forwarding/mapping messages.

Can you please help with this? Sorry for lack of knowledge on docker in case I am missing something.

Thanks in advance for help.

What’s the output of fly logs on this app? Maybe some errors pop up there.

@joshua , I was using the wrong env config. I had not count on the awesomeness of FLY.IO. We can define env so easily in fly.toml and rest is magic. I was using Dockerfile for setting my env which I think may have caused the issue. Anyways it is resolved now.

I am in love with awesome job guys. Remote docker build is like 10X Harry Potter :smile:

1 Like