From 934335f9cde01dda23975f339b4dc4c30d16e259 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Tue, 10 Sep 2024 16:41:51 +0200 Subject: [PATCH 1/4] fix: containers report wrong version Resolves: #1354 --- .circleci/config.yml | 11 ++++++++--- Dockerfile | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 587a51a3..4ce97bf1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,10 +9,11 @@ jobs: - MRIQC_API_TAG: 1.1.0 - MRIQC_API_DOCKER_IMAGES: "nginx:latest swaggerapi/swagger-ui:latest mongo:latest python:3.7-slim" + - DOCKER_BUILDKIT: 1 machine: # https://discuss.circleci.com/t/linux-machine-executor-images-2021-april-q2-update/39928 # upgrade Docker version - image: ubuntu-2204:2023.02.1 + image: default docker_layer_caching: true working_directory: /tmp/src/mriqc steps: @@ -126,10 +127,12 @@ jobs: name: Build Docker image no_output_timeout: 60m command: | - python3 -m pip install hatch + pyenv local 3 + pip install hatch # Get version before making repo dirty - THISVERSION=$( python3 -m hatch version ) + THISVERSION=$( hatch version ) + # Inject MRIQC-WebAPI secret if [ "${MRIQC_API_SECRET_TOKEN}" != "" ]; then sed -i -E "s//$MRIQC_API_SECRET_TOKEN/" mriqc/config.py @@ -143,6 +146,8 @@ jobs: echo "them to your fork with ``git push origin --tags``" fi + echo "Building version: $THISVERSION." + # Build docker image e=1 && for i in {1..5}; do docker build \ diff --git a/Dockerfile b/Dockerfile index 5ef43932..4fd53e7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -201,6 +201,7 @@ WORKDIR /tmp/ # Run mriqc by default ENTRYPOINT ["/opt/conda/bin/mriqc"] +ARG VERSION ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE \ From bd6b35d86b6c97e8f5d7c9d61a5169196f51baa4 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Tue, 10 Sep 2024 16:51:57 +0200 Subject: [PATCH 2/4] enh: add a test for version in built image --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ce97bf1..15be8d66 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -158,6 +158,9 @@ jobs: --build-arg VERSION="${CIRCLE_TAG:-$THISVERSION}" . \ && e=0 && break || sleep 15 done && [ "$e" -eq "0" ] + + DOCKER_VERSION=$( docker run --rm nipreps/mriqc:latest --version ) + test "${CIRCLE_TAG:-$THISVERSION}" == "$DOCKER_VERSION" - run: name: Docker push to local registry no_output_timeout: 40m From d8431789f5e89535c9c2a93a3e6e52484345be65 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Wed, 25 Sep 2024 13:52:54 +0200 Subject: [PATCH 3/4] Update .circleci/config.yml --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 15be8d66..2f1aee6c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -160,6 +160,8 @@ jobs: done && [ "$e" -eq "0" ] DOCKER_VERSION=$( docker run --rm nipreps/mriqc:latest --version ) + echo "Target version: \"${CIRCLE_TAG:-$THISVERSION}\"" + echo "Docker version: \"${DOCKER_VERSION}\"" test "${CIRCLE_TAG:-$THISVERSION}" == "$DOCKER_VERSION" - run: name: Docker push to local registry From af556f5efe89863aba8d74c2de13dfcb52fb7a01 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Wed, 25 Sep 2024 15:24:10 +0200 Subject: [PATCH 4/4] fix: circleci test on version within docker image --- .circleci/config.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f1aee6c..45c88d88 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -159,10 +159,13 @@ jobs: && e=0 && break || sleep 15 done && [ "$e" -eq "0" ] + TARGET_VERSION="${CIRCLE_TAG:-$THISVERSION}" + TARGET_VERSION="MRIQC v${TARGET_VERSION%+*}" DOCKER_VERSION=$( docker run --rm nipreps/mriqc:latest --version ) - echo "Target version: \"${CIRCLE_TAG:-$THISVERSION}\"" + DOCKER_VERSION="${DOCKER_VERSION%+*}" + echo "Target version: \"${TARGET_VERSION}\"" echo "Docker version: \"${DOCKER_VERSION}\"" - test "${CIRCLE_TAG:-$THISVERSION}" == "$DOCKER_VERSION" + test "${TARGET_VERSION}" == "$DOCKER_VERSION" - run: name: Docker push to local registry no_output_timeout: 40m