task-maker-rust icon indicating copy to clipboard operation
task-maker-rust copied to clipboard

Update Dockerfile

Open CristianCantoro opened this issue 3 months ago • 7 comments

This PR does the following:

  • Update base image from ubuntu:18.04 to ubuntu:24.04 (LTS release)
  • Update LABELs
  • Build task-maker-rust from source, since the .deb package is no longer available
  • Add support for running multiple workers (by default, run <nproc>-1 workers, or you can specify the number with -j)
Usage:
  entrypoint.sh [options]

Entrypoint for task-maker-rust Docker image.

Options:
  -j, --jobs NWORKERS    Number of workers to launch [default: <nproc>-1].
  -h, --help             Show this help and exits.

I think the image could be published on Docker Hub and/or distributed with the GitHub container registry.

h/t to @edomora97 for the guidance on the changes.

CristianCantoro avatar Sep 04 '25 21:09 CristianCantoro

A small note, if you build the image passing all the --build-args to populate the labels, the image will compile from scratch every time. It takes ~16.5 minutes on my machine.

docker build \
  --build-arg TM_VERSION=0.6.14 \
  --build-arg VCS_REF="$(git rev-parse HEAD)" \
  --build-arg BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
  -t cristiancantoro/task-maker-rust:0.6.14 \
    .

For dev/testing just build it like this:

docker build \
  --build-arg TM_VERSION=0.6.14 \
  -t cristiancantoro/task-maker-rust:0.6.14 \
    .

CristianCantoro avatar Sep 04 '25 22:09 CristianCantoro

Why doesn't the dockerfile just add the APT repository and add the package from there? That seems way simpler than most other alternatives, it should boil down to roughly three commands:

echo "deb [signed-by=/etc/apt/keyrings/task-maker-rust.asc] https://artifacts.lucaversari.it/olimpiadi-informatica/task-maker-rust/latest/deb/$(lsb_release -cs) /" | sudo tee /etc/apt/sources.list.d/task-maker-rust.list
curl https://artifacts.lucaversari.it/signing-key.asc | sudo tee /etc/apt/keyrings/task-maker-rust.asc > /dev/null
sudo apt update && sudo apt install task-maker-rust

veluca93 avatar Sep 06 '25 08:09 veluca93

@veluca93 wrote:

Why doesn't the dockerfile just add the APT repository and add the package from there? That seems way simpler than most other alternatives, it should boil down to roughly three commands:

When I sat down to write the new Dockerfile I decided that I was going to use what I found in the release page and so I downloaded and built task-maker-rust from source without thinking twice. Funnily enough, on my machine I actually installed your .deb package.

CristianCantoro avatar Sep 07 '25 18:09 CristianCantoro

Why doesn't the dockerfile just add the APT repository and add the package from there? That seems way simpler than most other alternatives, it should boil down to roughly three commands:

echo "deb [signed-by=/etc/apt/keyrings/task-maker-rust.asc] https://artifacts.lucaversari.it/olimpiadi-informatica/task-maker-rust/latest/deb/$(lsb_release -cs) /" | sudo tee /etc/apt/sources.list.d/task-maker-rust.list
curl https://artifacts.lucaversari.it/signing-key.asc | sudo tee /etc/apt/keyrings/task-maker-rust.asc > /dev/null
sudo apt update && sudo apt install task-maker-rust

I'm a bit of a noob, but can you install a specific old version of tmr from the APT repository?

edomora97 avatar Sep 08 '25 11:09 edomora97

Why doesn't the dockerfile just add the APT repository and add the package from there? That seems way simpler than most other alternatives, it should boil down to roughly three commands:

echo "deb [signed-by=/etc/apt/keyrings/task-maker-rust.asc] https://artifacts.lucaversari.it/olimpiadi-informatica/task-maker-rust/latest/deb/$(lsb_release -cs) /" | sudo tee /etc/apt/sources.list.d/task-maker-rust.list
curl https://artifacts.lucaversari.it/signing-key.asc | sudo tee /etc/apt/keyrings/task-maker-rust.asc > /dev/null
sudo apt update && sudo apt install task-maker-rust

I'm a bit of a noob, but can you install a specific old version of tmr from the APT repository?

Yup, see https://askubuntu.com/a/428778 -- tldr: sudo apt-get install package=version.

veluca93 avatar Sep 08 '25 13:09 veluca93

Sorry for the delay, this is what I have changed:

  • now task-maker-rust is installed using the deb package from the release page.
  • I have converted entrypoint.sh to entrypoint.py (with logging)
  • I have changed the user name from taskmaker to task-maker

I saw that @veluca93's APT repo only contains the latest version of task-maker-rust, I assume it is ok to install the package from the release.

If, for whatever reason, you prefer that the Dockerfile installs the deb from the APT repository then Dockerfile#L71-L78 should be changed to the following:

# install task-maker-rust from APT repo
ARG TM_DEB_VERSION="${TM_VERSION}-1~ubuntu-24.04"
ARG TM_DEB_NAME="task-maker-rust_${TM_DEB_VERSION}_amd64.deb"

RUN (test -n "$TM_VERSION" || (echo "Please use --build-arg TM_VERSION=X.Y.Z" >&2 && exit 1)) \
  && . /etc/os-release \
  && echo "deb [signed-by=/etc/apt/keyrings/task-maker-rust.asc] https://artifacts.lucaversari.it/olimpiadi-informatica/task-maker-rust/latest/deb/${UBUNTU_CODENAME} /" \
      | tee /etc/apt/sources.list.d/task-maker-rust.list \
  && curl https://artifacts.lucaversari.it/signing-key.asc \
      | tee /etc/apt/keyrings/task-maker-rust.asc > /dev/null \
  && apt update \
  && apt install -yy task-maker-rust="${TM_DEB_VERSION}" \
  && rm -rf /var/lib/apt/lists/*

(note that the deb package name is ~ubuntu-XX.YY instead of .ubuntu-XX.YY)

CristianCantoro avatar Sep 16 '25 02:09 CristianCantoro

I have also updated healthcheck.sh to check that all expected workers are running.

CristianCantoro avatar Sep 16 '25 03:09 CristianCantoro