From 2edee2b2c7908696d9e6c23e46e96c4840691917 Mon Sep 17 00:00:00 2001 From: Marcel Loose <loose@astron.nl> Date: Fri, 7 Feb 2025 13:24:53 +0000 Subject: [PATCH] Update build script for building a docker image --- .gitlab-ci.yml | 4 +-- Docker/Dockerfile-linc | 4 +-- Docker/build_docker.sh | 64 ++++++++++++++++++++++++++++++++++++++---- README.md | 6 ++-- 4 files changed, 65 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b887625..7c9238c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -194,10 +194,8 @@ build_base: $DOCKER_CACHE_PARAMETERS \ --build-arg CASACORE_COMMIT \ --build-arg LOFARSTMAN_COMMIT \ - --build-arg DYSCO_COMMIT \ --build-arg IDG_COMMIT \ --build-arg AOFLAGGER_COMMIT \ - --build-arg LOFARBEAM_COMMIT \ --build-arg EVERYBEAM_COMMIT \ --build-arg SAGECAL_COMMIT \ --build-arg DP3_COMMIT \ @@ -225,7 +223,7 @@ install_linc: fi docker build \ $DOCKER_CACHE_PARAMETERS \ - --build-arg BASE_TAG=$INTEGRATION_BASE_IMAGE \ + --build-arg BASE_IMAGE=$INTEGRATION_BASE_IMAGE \ --build-arg LINC_VERSION=$LINC_VERSION \ --file Docker/Dockerfile-linc \ --tag $INTEGRATION_IMAGE \ diff --git a/Docker/Dockerfile-linc b/Docker/Dockerfile-linc index 61865a76..c49ae8d6 100644 --- a/Docker/Dockerfile-linc +++ b/Docker/Dockerfile-linc @@ -1,5 +1,5 @@ -ARG BASE_TAG=latest -FROM $BASE_TAG +ARG BASE_IMAGE +FROM $BASE_IMAGE ENV EVERYBEAM_DATADIR=/usr/local/share/everybeam \ LINC_DATA_ROOT=/usr/local/share/linc \ diff --git a/Docker/build_docker.sh b/Docker/build_docker.sh index b7d00fa9..c780519b 100755 --- a/Docker/build_docker.sh +++ b/Docker/build_docker.sh @@ -1,7 +1,61 @@ -#! /bin/bash -set -e +#!/bin/bash +# +# This script build the base docker image and the full docker image for LINC. +# It is inspired by the way the docker images are built in the CI/CD pipeline +# (described in the `.gitlab-ci.yml` file). -DOCKER_TAG=latest +set -euo pipefail -docker build ${PWD}/.. -f Dockerfile-base -t ${DOCKER_TAG} && \ -docker build ${PWD}/.. -f Dockerfile-linc -t astronrd/linc:${DOCKER_TAG} \ No newline at end of file +SCRIPT_DIR=$(cd "$(dirname "${0}")" && pwd) +REPO_ROOT="$(git rev-parse --show-toplevel)" + +echo "Determining version information ..." +eval $(${SCRIPT_DIR}/fetch_commit_hashes.sh | tee commits.txt) + +BASE_NAME=linc-base +BASE_TAG=$(sha256sum commits.txt | cut -d" " -f1) +BASE_IMAGE=${BASE_NAME}:${BASE_TAG} +FULL_NAME=linc-full +FULL_TAG=$(git log -n 1 --pretty=format:%H) +FULL_IMAGE=${FULL_NAME}:${FULL_TAG} +LINC_VERSION=$(${SCRIPT_DIR}/get_scm_version.sh) +LINC_NAME=astronrd/linc +LINC_TAG=${LINC_VERSION//[^[:alnum:]_.-]/-} +LINC_IMAGE=${LINC_NAME}:${LINC_TAG} + +# Build the base image, using the previously determined git commit hashes for +# the packages we need to build +docker build \ + --build-arg CASACORE_COMMIT=${CASACORE_COMMIT} \ + --build-arg LOFARSTMAN_COMMIT=${LOFARSTMAN_COMMIT} \ + --build-arg IDG_COMMIT=${IDG_COMMIT} \ + --build-arg AOFLAGGER_COMMIT=${AOFLAGGER_COMMIT} \ + --build-arg EVERYBEAM_COMMIT=${EVERYBEAM_COMMIT} \ + --build-arg SAGECAL_COMMIT=${SAGECAL_COMMIT} \ + --build-arg DP3_COMMIT=${DP3_COMMIT} \ + --build-arg WSCLEAN_COMMIT=${WSCLEAN_COMMIT} \ + --build-arg PYTHONCASACORE_COMMIT=${PYTHONCASACORE_COMMIT} \ + --build-arg LINC_VERSION=${LINC_VERSION} \ + --progress plain \ + --file ${SCRIPT_DIR}/Dockerfile-base \ + --tag ${BASE_IMAGE} \ + ${REPO_ROOT} + +# Build the full image, taking the base image as starting point +docker build \ + --build-arg BASE_IMAGE=${BASE_IMAGE} \ + --build-arg LINC_VERSION=${LINC_VERSION} \ + --progress plain \ + --file ${SCRIPT_DIR}/Dockerfile-linc \ + --tag ${FULL_IMAGE} \ + ${REPO_ROOT} + +# Tag the full image with LINC version number +docker tag \ + ${FULL_IMAGE} \ + ${LINC_IMAGE} + +# Tag the full image as latest +docker tag \ + ${FULL_IMAGE} \ + latest diff --git a/README.md b/README.md index 83f8a0b4..53a709ad 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ The full documentation can be found at the [LINC webpage](https://linc.readthedo * [WSClean](https://gitlab.com/aroffringa/wsclean) (v3.5 or later) * [IDG](https://gitlab.com/astron-idg/idg) (v0.7 or later) * [LofarStMan](https://github.com/lofar-astron/LofarStMan) -* [Dysco](https://github.com/aroffringa/dysco.git) (v1.3 or later) -* casacore -* Python3 (including matplotlib, scipy, astropy) +* [casacore] (https://github.com/casacore/casacore) (v3.5 or later) +* [python-casacore] (https://github.com/casacore/python-casacore) (v3.5 or later) +* Python (including matplotlib, scipy, astropy, etc.) (v3.8 or later) * [cwltool](https://github.com/common-workflow-language/cwltool) (3.1.20231207110929 or later) * [toil-cwl-runner](https://github.com/DataBiosphere/toil) (6.0.0 or later) -- GitLab