docker-library / ruby

Docker Official Image packaging for Ruby
http://www.ruby-lang.org/
BSD 2-Clause "Simplified" License
590 stars 334 forks source link

ruby 2.3.1 suddenly stopped working with apt-get update #409

Closed luke-hill closed 1 year ago

luke-hill commented 1 year ago

EDIT: I originally had an issue where the apt-get update commands were failing. I have now managed to fix this. So I'll post the two solutions below and a little bit of insight why...

Solution Points

Easy solution

Updating to ruby:2.4 works. (Must be the latest one)

Harder solution

FYI Anyone being redirected here after finding this issue....

I have found out that this is because even though Jessie went EOL years ago, it pulled most references recently (March '23). A combination of a variety of SO posts cut and pasted together will yield a result. Essentially I have tricked the system into using Stretch based upstream sources

Before running apt-get update you need to....

# We need to hack into our apt package manager distro and forcibly change the upstream from Debian 8->9
# This will enable us to then find the old "existing" packages to enable our Dockerfile to compile
RUN echo "deb http://httpredir.debian.org/debian stretch main contrib non-free" > /etc/apt/sources.list
RUN echo "deb http://httpredir.debian.org/debian stretch-updates main contrib non-free" >> /etc/apt/sources.list
RUN echo "deb http://security.debian.org stretch/updates main contrib non-free" >> /etc/apt/sources.list

# We need to add a secondary backported support upstream link. We will use this to install `npm` alone as this was never
# Supported in Debian 9 (But was in Debian 8 and 10 for some reason)
RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch-backports.list

NB: The first echo command is deliberately clobbering (>) the sources to wipe out all trace of jessie. Then the remaining 2 are to append (>>).

Then later on if you need JS there are some more issues ....

# We need to install npm first using the stretch-backports package list
RUN apt-get -t stretch-backports install npm -y --allow-unauthenticated

# We need to install nodejs and then we're able to install `n` to use legacy node (v8)
RUN apt-get install -y --force-yes nodejs && \
    npm i -g n

# We must use the `n` package in a different thread to above as the node version must auto-switch
# after the `n` version of node is configured
RUN n 8.10 && npm i

NB: Note that n runs in a different thread. This was causing issues when chained. I have no idea why, but unchaining them works! Also note the usage of the tagged backports upstream source for stretch. npm won't install by default you need to use this specific endpoint

tianon commented 1 year ago

Unfortunately, we do not have the bandwidth to provide in-depth integration/deployment/environment debugging or support here; these sorts of questions/requests would be more appropriately posted to a dedicated support forum, such as the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow.

yosifkit commented 1 year ago

Like Ruby 2.3, Debian Jessie is also long past end of life (and LTS). Some possible workarounds in https://github.com/docker-library/ruby/issues/394, but I think it was finally pulled from Debian mirrors and so those may not work at all.

luke-hill commented 1 year ago

@yosifkit Yes, the Debian mirrors were pulled. I think I've half managed to cobble together some answers. I'll update my initial post with some findings.

Apologies if this was the wrong forum @tianon - I did search around correctly. SO was not much use as I mentioned in my OP. And this felt the correct area