App updated from old-style machine to new-style machine no longer works

I had an app (my personal website), built via Next.js, deployed on Fly for quite a while.

I just updated the fly CLI, and ran fly deploy - and it looks like it created new-style machines, ie: I noticed that in my machines tab I had two new machines + still had my old machine.

I finally destroyed my old machine: and noticed that the new machines don’t work at all, ie: I see no informative messages + I just get timeouts when sending any requests.

It looks like the update path is broken somehow?

Here’s my fly.toml + Dockerfile:


# fly.toml app configuration file generated for venki-dev on 2023-06-19T18:06:00-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "venki-dev"
primary_region = "sjc"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 1

Dockerfile:

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.13.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Next.js"

# Next.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV=production
ENV SKIP_ENV_VALIDATION=1
ENV NOTION_SECRET=...
ENV NOTION_DATABASE_ID=...

# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install -y python-is-python3 pkg-config build-essential 

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link . .

# Build application
RUN npm run build

# Remove development dependencies
RUN npm prune --omit=dev


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start" ]

Would appreciate any tips on fixing this for the new machines :slight_smile:

Okay, I fixed it!
The trick: I looked through more recent Next.js → Fly.io deployment templates, and found this: GitHub - nextjs/deploy-fly: Next.js template to deploy to Fly with a Docker container.

I then copied over their Dockerfile, which fixed things:

FROM node:lts-alpine AS base

# Stage 1: Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --include=dev

# Stage 2: Build the application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NOTION_SECRET=...
ENV NOTION_DATABASE_ID=...
RUN npm run build
RUN npm prune --omit=dev

# Stage 3: Production server
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NOTION_SECRET=...
ENV NOTION_DATABASE_ID=...

# Copy built application
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public

EXPOSE 3000
CMD ["node", "server.js"]

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.