How to move off Debian Buster while still keeping a legacy version of Node?

Hello,
This is a node.js application.
I haven’t deployed in a month or so but now I am getting this error. No changes were made since the last time so I’m a little confused as to why it would have suddenly break.
I have already ran npx --yes @flydotio/dockerfile@latest and npm install

 => ERROR [build 1/4] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python                                                                                                           0.2s 
------
 > [build 1/4] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python:
0.145 E: The repository 'http://security.debian.org/debian-security buster/updates Release' does not have a Release file.
0.145 E: The repository 'http://deb.debian.org/debian buster Release' does not have a Release file.
0.145 E: The repository 'http://deb.debian.org/debian buster-updates Release' does not have a Release file.
------
Error: failed to fetch an image or build from source: error building: failed to solve: process "/bin/sh -c apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python" did not complete successfully: exit code: 100
1 Like

I think the buster image is deprecated. You should use bookworm or bullseye

I’m having this problem too and I though I see people saying I should update debian I’m not exactly sure how to

Do either of you have a Dockerfile in your project? I haven’t used the deployment workflow in GitHub, which I think tries to introspect stuff from your project type; if you are using this deployment approach, does it create a Dockerfile for you?

Aha, see here:

Our best scanners furnish a Dockerfile from which your app’s image will be built. Some of our terrible older scanners may invoke buildpacks, which tend to be slow and brittle.

So whether you have a Dockerfile supplied by this system, or you wrote your own, have a look at the FROM line, which will likely contain the offending Debian image.

I do have a Dockerfile, this is my “FROM” line:

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

I’ve been trying to change it (for example, to FROM node:16 or FROM node:16-bookworm-slim, but then I get authentication errors

Try ARG NODE_VERSION=18.20, which matches this public tag. I think Node 18 is pretty old, but if you’re running 16, there may be value in bumping up gently, until your code needs an adjustment.

but then I get authentication errors

I think that happens if you select a tag that does not exist in the Docker Hub catalogue. You can do a search here if you want to experiment.

Ah, I just tried pulling that locally; I get this:

Error response from daemon: manifest for node:16-bookwork-slim not found: manifest unknown: manifest unknown

I would guess that it has been removed from the catalogue, due to its age. I think you’re going to have to upgrade your Node version, unfortunately :upside_down_face:

Updating to 18.2 breaks my application :')

I’m trying to use other tags but I get this

=> ERROR [internal] load metadata for docker.io/library/base:latest

[internal] load metadata for docker.io/library/base:latest:

Error: failed to fetch an image or build from source: error building: failed to solve: base: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

You might be able to use a recent-ish version of Debian and install Node 16 on it. But could you just update your app? You’re going to have to at some point, just to ensure the app is not vulnerable. See this chart; I’d aim for 22 as minimum now.

Ah, interestingly one can still pull Node 16 as a Debian repo. You OK with adding that into your Dockerfile? You’ll need a standard, non-Node Docker image, and then install Node manually.

I’m absolutely open to it and I’m trying to do that now but to be honest I don’t know much about Docker and never even heard of Debian before today. So I’m just googling stuff and trying it. So far I’m here:

FROM debian:latest

# Install dependencies
RUN apt-get update && apt-get install -y \
    curl \
    gnupg \
    && rm -rf /var/lib/apt/lists/*

# Add NodeSource repository and install Node.js
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
RUN nvm install 16.0

# Verify installation
RUN node -v

But I still get the error

 => ERROR [internal] load metadata for docker.io/library/base:latest                                          0.4s
------
 > [internal] load metadata for docker.io/library/base:latest:
------
Error: failed to fetch an image or build from source: error building: failed to solve: base: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Do I need to download docker? log in somehow? I think it’s the FROM line that’s been causing issues this whole time but I’m not sure what to do especially since it’s being pulled through fly.io

Hmm, this is a bit weird; your FROM is debian:latest, which is available in the public catalogue, but the error from Fly doesn’t mention debian at all. Are you sure you’ve committed that FROM change? Maybe have a look in GitHub to see what you’ve pushed.

It’s helpful to have it available locally for testing, but not necessary for what you’re doing.

Nope.

His original FROM line had an as base at the end, but the new attempt dropped that.

(The as base technique is typical of multi-stage Dockerfiles, as you probably know.)

1 Like

I’m not pushing it to Git rn, just running fly deploy from the terminal

Ah yes, so it is getting stuck on a later stage that needs base; good spot.

The Dockerfile above doesn’t build; it cannot find nvm. Let me try something…

Adding as base worked, but yeah now the nvm doesn’t work

Try this; it builds successfully on my local machine:

FROM debian:latest

# Install dependencies
RUN apt-get update && apt-get install -y curl gnupg

RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -

RUN apt-get update && apt-get install -y nodejs

# Verify installation
RUN node -v

You can add the /var/lib/apt/lists/* tidying back if you want, I think it’s only to save a bit of space in the final image.

Do bear in mind though that your app may still fail to work if it relied on something in the old version of Debian. If that is the case you can probably roll back to an older Debian and have this still work.

For me this installs v16.20.2, which may not match the version you were previously running.

Finally you should probably pin to something more accurate than latest, otherwise your app may break when a new major version of Debian comes out :collision:

Thank you so much! I finally got it working. You and @mayailurus are lifesavers haha

2 Likes