Is it possible to install tools from github using their latest nightly build inside a Dockerfile?

I’m currently working on a Dockerfile locally and basing the image on ubuntu 20.04.

I have some of the standard stuff for installing apt and pip packages set up, but I’m wondering if there’s a way to install a tool from github using the latest available nightly build, ie. from the latest linux.tgz file here

# Use the official image as a parent image
FROM ubuntu:20.04

# Add Jenkins as a user with sufficient permissions
RUN mkdir /home/jenkins
RUN groupadd -g 136 jenkins
RUN useradd -r -u 126 -g jenkins -G plugdev -d /home/jenkins jenkins
RUN chown jenkins:jenkins /home/jenkins

WORKDIR /home/jenkins
CMD ["/bin/bash"]
ENV DEBIAN_FRONTEND=noninteractive 

# Install prerequisites
RUN apt-get update && apt-get install -y \
    lots_of_packages
    ...
    && rm -rf /var/lib/apt/lists/*
RUN pip3 install --user --upgrade poetry etc. etc.

RUN **(this is where I would like to install the tools from github using their latest nightly build)**

RUN export
USER jenkins
EXPOSE 8080
COPY . .

If you can find the compatible, pre-built release on GitHub, you can use curl to download it and tar to extract it. The process is the same with or without Docker if you need to automate the installation instead of doing it interactively on a desktop machine. Try to write a script on the host which uses curl to download the release and tar to extract it. If that works, you can copy the code to Dockerfile and build the image.

If you have a more specific problem with the process, show us what you tried and what error messages you got.

Curl / tar for a specific release is what I have running but was wondering if there was a clever way to pull from the latest release on the page instead of a hardcoded .x.x.tar value in my curl string.

I think the “clever way” in a Dockerfile is a specific version and never the latest, but since you asked about the latest, I try to answer that. I don’t think you can download the latest release with a simple URL like an alias to the one latest tar or exe since a release can have multiple files for different platforms. You can however use the GitHub API to find out what the latest available files.

If you know how those files are named, you can find the proper version. The following example will get the URL of the last uploaded file:

curl -s https://api.github.com/repos/YosysHQ/oss-cad-suite-build/releases/latest | jq --raw-output '.assets[0].browser_download_url'

If you know you need the Linux ARM64 version, you can try a little more complex jq filter:

curl -s https://api.github.com/repos/YosysHQ/oss-cad-suite-build/releases/latest | jq --raw-output '[.assets[] | select(.browser_download_url | test("linux-arm64"))][0] | .browser_download_url'

Or you can use grep instead of a long jq filter:

curl -s "https://api.github.com/repos/YosysHQ/oss-cad-suite-build/releases/latest?per_page=100" | jq --raw-output '.assets[].browser_download_url | grep "linux-arm64"' | head -n1

Then you can use that url to pass to an other curl command:

curl -L $(curl -s "https://api.github.com/repos/YosysHQ/oss-cad-suite-build/releases/latest" | jq --raw-output '.assets[].browser_download_url' | grep "linux-arm64" | head -n1) --output /app/arm.tar.gz

If too there are too many attached versions, you may need to use the per_page parameter

curl -L $(curl -s "https://api.github.com/repos/YosysHQ/oss-cad-suite-build/releases/latest?per_page=100" | jq --raw-output '.assets[].browser_download_url' | grep "linux-arm64" | head -n1) --output /app/arm.tar.gz

I meant latest under the assumption that there would be new versions released after selecting whichever happens to be the latest at the time of creating the Docker image, but your solution looks great! Thank you! I’ll try this out and see if I can get it to work.