Hello!
After spinning up a new next.js app and running fly deploy
, I received the following error:
#8 2.968 E: Package 'python' has no installation candidate
------
Error: failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c apt-get update -qq && apt-get install -y python pkg-config build-essential]: exit code: 100
This must be related to the Dockerfile for Node.js that is automatically generated:
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18
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
# 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 pkg-config build-essential
# Install node modules
COPY --link package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production=false
# Copy application code
COPY --link . .
# Build application
RUN yarn run build
# Remove development dependencies
RUN yarn install --production=true
# 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 [ "yarn", "run", "start" ]
I don’t think we need to install python to install node.js:
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y python pkg-config build-essential
While we’re here, I would set the default node version from 16 to 20, since Node v20 is about to become “current” in a couple of months anyway: GitHub - nodejs/Release: Node.js Release Working Group