All images can be built locally from their respective directories. It is encouraged the inclusion of a BUILD.md
file with the specific docker build
command used, specially if the build command requires build arguments.
If not provided, the image should be build with docker build ./ -t pegi3s/image_name:image_version && docker tag pegi3s/image_name:image_version pegi3s/image_name:latest
.
Some images are configured to be built automatically from Docker Hub using the Automated Builds feature. This is specially interesting for software packages that are frequently updated (e.g. BLAST, SeqKit, sratoolkit, and so on), as the built can be triggered directly at Docker Hub without making a commit.
The Dockerfiles of such images have a VERSION
argument that specifies the software version that should be downloaded. This way, the Dockerfile is generic and can be used to build an image for any software version (available at the releases URL). For instance, this is the sratoolkit Dockerfile:
FROM ubuntu:22.04
ARG VERSION
RUN apt-get update \
&& apt-get install -y wget libxml-libxml-perl
RUN wget https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/${VERSION}/sratoolkit.${VERSION}-ubuntu64.tar.gz -O /tmp/sratoolkit.tar.gz \
&& tar zxvf /tmp/sratoolkit.tar.gz -C /opt/ && rm /tmp/sratoolkit.tar.gz
ENV PATH="/opt/sratoolkit.${VERSION}-ubuntu64/bin/:${PATH}"
The Docker Hub advanced options for autobuild allows setting a build configuration to built such images. This requires three things:
- Set the automated builds configuration as follows. There is only one build rule for the latest image and then the
VERSION
environment variable with the specific software version.
-
A
build
hook script as the following. When present at thehooks
directory, Docker Hub uses it to build the Docker image. In this case, it takes theVERSION
environment variable and, if present, passes it to thedocker build
command. The image is created with thelatest
tag.#!/bin/bash if [ -z ${VERSION} ]; then echo "VERSION environment variable not set." exit 1 else echo "Building ${VERSION}" docker build -f ${DOCKERFILE_PATH} --build-arg VERSION=${VERSION} -t ${IMAGE_NAME} . fi
-
A
post_push
hook script to tag thelatest
image build in the previous step asour_image:version
. The following script tags the image and pushes it to the associated repository.#!/bin/bash if [ -z ${VERSION} ]; then echo "VERSION environment variable not set." exit 1 else echo "Tagging ${IMAGE_NAME} as ${DOCKER_REPO}:${VERSION}" docker tag ${IMAGE_NAME} ${DOCKER_REPO}:${VERSION} docker push ${DOCKER_REPO}:${VERSION} fi