diff --git a/.github/workflows/civ2.yml b/.github/workflows/civ2.yml new file mode 100644 index 0000000..e813c91 --- /dev/null +++ b/.github/workflows/civ2.yml @@ -0,0 +1,89 @@ +name: Build and Push Image +on: push + +jobs: + ci: + name: Build Image and Push + runs-on: ubuntu-latest + steps: + # https://github.com/docker/login-action#quayio + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_ROBOT_TOKEN }} + + # # https://github.com/docker/login-action#aws-public-elastic-container-registry-ecr + # - name: Login to ECR + # uses: docker/login-action@v3 + # with: + # registry: ${{ inputs.AWS_ECR_REGISTRY }} + # username: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} + # password: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} + # env: + # AWS_REGION: ${{ inputs.AWS_REGION }} + + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.3.0 + + - name: Set Variables + shell: bash + run: | + echo "IMAGE_TAG=$(echo ${GITHUB_REF#refs/*/} | tr / _)" + echo "IMAGE_TAG=$(echo ${GITHUB_REF#refs/*/} | tr / _)" >> $GITHUB_ENV + + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + quay.io/cdis/${{ env.REPO_NAME }}:${{ env.IMAGE_TAG }} + # ${{ inputs.AWS_ECR_REGISTRY }}/gen3/${{ env.REPO_NAME }}:${{ env.IMAGE_TAG }} + + # - name: Build and push + # if: ${{ !inputs.USE_QUAY_ONLY }} + # uses: docker/build-push-action@v6 + # # You may get ECR-push errors when first adding the workflow to a github repo. + # # If so, run the following in dev/qa to create the ECR repository: + # # qaplanetv1@cdistest_dev_admin:~$ aws ecr create-repository --repository-name "gen3/" --image-scanning-configuration scanOnPush=true + # with: + # context: ${{ inputs.DOCKERFILE_BUILD_CONTEXT }} + # file: ${{ inputs.DOCKERFILE_LOCATION }} + # push: true + # tags: | + # ${{ inputs.AWS_ECR_REGISTRY }}/gen3/${{ env.REPO_NAME }}:${{ env.IMAGE_TAG }} + # quay.io/cdis/${{ env.REPO_NAME }}:${{ env.IMAGE_TAG }} + # labels: ${{ steps.meta.outputs.labels }} + # cache-from: type=registry,ref=${{ inputs.AWS_ECR_REGISTRY }}/gen3/${{ env.REPO_NAME }}:cache + # cache-to: type=registry,ref=${{ inputs.AWS_ECR_REGISTRY }}/gen3/${{ env.REPO_NAME }}:cache,mode=max,image-manifest=true,oci-mediatypes=true + # platforms: ${{ inputs.BUILD_PLATFORMS }} + + # - name: Build and push (Quay only) + # if: ${{ inputs.USE_QUAY_ONLY }} + # uses: docker/build-push-action@v6 + # with: + # context: ${{ inputs.DOCKERFILE_BUILD_CONTEXT }} + # file: ${{ inputs.DOCKERFILE_LOCATION }} + # push: true + # tags: | + # quay.io/cdis/${{ env.REPO_NAME }}:${{ env.IMAGE_TAG }} + # labels: ${{ steps.meta.outputs.labels }} + # platforms: ${{ inputs.BUILD_PLATFORMS }} + + # TODO linux/arm64 image + - name: Build linux/amd64 image + run: ./local-build.sh version=stable platform=linux/amd64 image=normal type=ci step=build currentTag=${{ env.IMAGE_TAG }}-normal-stable + + - name: Push linux/amd64 image + run: ./local-build.sh version=stable platform=linux/amd64 image=normal type=ci step=push currentTag=${{ env.IMAGE_TAG }}-normal-stable pushTag=${{ env.IMAGE_TAG }} isTag=true \ No newline at end of file diff --git a/backup_.github/workflows/build-docker.yml b/backup_.github/workflows/build-docker.yml index 335be1d..927a759 100644 --- a/backup_.github/workflows/build-docker.yml +++ b/backup_.github/workflows/build-docker.yml @@ -1,7 +1,3 @@ -name: Build Image and Push to Registries - -on: push - on: workflow_call: inputs: @@ -56,13 +52,7 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }} steps: - # https://github.com/docker/login-action#quayio - - name: Login to Quay.io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_USERNAME }} - password: ${{ secrets.QUAY_ROBOT_TOKEN }} + # - name: Maximize build space # uses: easimon/maximize-build-space@v10 @@ -134,25 +124,25 @@ jobs: # timeout-minutes: 30 - name: Build normal image with local-build.sh - run: ./local-build.sh version=stable platform=linux/amd64 image=normal type=ci step=build currentTag=${{ inputs.current_branch_tag }}-normal-stable + run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=normal type=ci step=build currentTag=${{ inputs.current_branch_tag }}-normal-${{ inputs.stable_unstable }} - # - name: Install Integration tests prerequisites - # run: sudo apt-get install -y dcmtk + - name: Install Integration tests prerequisites + run: sudo apt-get install -y dcmtk - # - name: Run normal image integration tests - # # TODO: enable on ARM64 too - # if: inputs.runner_type == 'github-hosted' - # run: ./run-integration-tests.sh version=${{ inputs.stable_unstable }} image=normal tagToTest=${{ inputs.current_branch_tag }}-normal-${{ inputs.stable_unstable }} - # working-directory: ${{github.workspace}}/docker/integration-tests + - name: Run normal image integration tests + # TODO: enable on ARM64 too + if: inputs.runner_type == 'github-hosted' + run: ./run-integration-tests.sh version=${{ inputs.stable_unstable }} image=normal tagToTest=${{ inputs.current_branch_tag }}-normal-${{ inputs.stable_unstable }} + working-directory: ${{github.workspace}}/docker/integration-tests - # - name: Build full image with local-build.sh - # run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=full type=ci step=build currentTag=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} + - name: Build full image with local-build.sh + run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=full type=ci step=build currentTag=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} - # - name: Run full image integration tests - # # TODO: enable on ARM64 too - # if: inputs.runner_type == 'github-hosted' - # run: ./run-integration-tests.sh version=${{ inputs.stable_unstable }} image=full tagToTest=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} - # working-directory: ${{github.workspace}}/docker/integration-tests + - name: Run full image integration tests + # TODO: enable on ARM64 too + if: inputs.runner_type == 'github-hosted' + run: ./run-integration-tests.sh version=${{ inputs.stable_unstable }} image=full tagToTest=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} + working-directory: ${{github.workspace}}/docker/integration-tests # - name: Setup tmate session # uses: mxschmitt/action-tmate@v3 @@ -161,22 +151,22 @@ jobs: # timeout-minutes: 30 - name: Push normal image with branch/tag - run: ./local-build.sh version=stable platform=linux/amd64 image=normal type=ci step=push currentTag=${{ inputs.current_branch_tag }}-normal-stable pushTag=${{ inputs.current_branch_tag }} + run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=normal type=ci step=push currentTag=${{ inputs.current_branch_tag }}-normal-${{ inputs.stable_unstable }} pushTag=${{ inputs.current_branch_tag }} isTag=${{ inputs.is_tag }} - # - name: Push full image with branch/tag - # run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=full type=ci step=push currentTag=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} pushTag=${{ inputs.current_branch_tag }}-full isTag=${{ inputs.is_tag }} + - name: Push full image with branch/tag + run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=full type=ci step=push currentTag=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} pushTag=${{ inputs.current_branch_tag }}-full isTag=${{ inputs.is_tag }} - # - name: Push normal image with latest tag - # if: inputs.is_tag == 'true' - # run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=normal type=ci step=push currentTag=${{ inputs.current_branch_tag }}-normal-${{ inputs.stable_unstable }} pushTag=latest isTag=${{ inputs.is_tag }} + - name: Push normal image with latest tag + if: inputs.is_tag == 'true' + run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=normal type=ci step=push currentTag=${{ inputs.current_branch_tag }}-normal-${{ inputs.stable_unstable }} pushTag=latest isTag=${{ inputs.is_tag }} - # - name: Push full image with latest tag - # if: inputs.is_tag == 'true' - # run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=full type=ci step=push currentTag=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} pushTag=latest-full isTag=${{ inputs.is_tag }} + - name: Push full image with latest tag + if: inputs.is_tag == 'true' + run: ./local-build.sh version=${{ inputs.stable_unstable }} platform=${{ inputs.platform }} image=full type=ci step=push currentTag=${{ inputs.current_branch_tag }}-full-${{ inputs.stable_unstable }} pushTag=latest-full isTag=${{ inputs.is_tag }} - # - name: Setup tmate session - # if: ${{ failure() && inputs.runner_type == 'github-hosted' }} - # uses: mxschmitt/action-tmate@v3 - # with: - # limit-access-to-actor: true - # timeout-minutes: 20 + - name: Setup tmate session + if: ${{ failure() && inputs.runner_type == 'github-hosted' }} + uses: mxschmitt/action-tmate@v3 + with: + limit-access-to-actor: true + timeout-minutes: 20 \ No newline at end of file diff --git a/bash-helpers.sh b/bash-helpers.sh index 679de11..b105f30 100755 --- a/bash-helpers.sh +++ b/bash-helpers.sh @@ -239,14 +239,12 @@ getCommitId() { # $1 = name, $2 = version (stable or unstable), $3 = platform (m repoType=$(getFromMatrix $1 repoType) if [[ $repoType == "hg" ]]; then - commit_id=$(getHgCommitId $repo $revision) + echo $commit_id elif [[ $repoType == "git" ]]; then - commit_id=$(getGitCommitId $repo $revision) fi - echo $commit_id } diff --git a/local-build.sh b/local-build.sh index 75085b4..a18c7ec 100755 --- a/local-build.sh +++ b/local-build.sh @@ -239,25 +239,25 @@ fi add_host_cmd=--add-host=orthanc.uclouvain.be:130.104.229.21 -###### runner-base -docker $build \ - $add_host_cmd \ - --progress=plain --platform=$platform -t orthancteam/orthanc-runner-base:$BASE_BUILDER_IMAGE_TAG \ - --build-arg BASE_DEBIAN_IMAGE=$BASE_DEBIAN_IMAGE \ - $from_cache_arg_runner_base \ - $to_cache_arg_runner_base \ - $push_load_arg_builder_image \ - -f docker/orthanc/Dockerfile.runner-base docker/orthanc - -###### builder-base -docker $build \ - $add_host_cmd \ - --progress=plain --platform=$platform -t orthancteam/orthanc-builder-base:$BASE_BUILDER_IMAGE_TAG \ - $from_cache_arg_builder_base \ - $to_cache_arg_builder_base \ - $push_load_arg_builder_image \ - --build-arg BASE_IMAGE_TAG=$BASE_BUILDER_IMAGE_TAG \ - -f docker/orthanc/Dockerfile.builder-base docker/orthanc +# ###### runner-base +# docker $build \ +# $add_host_cmd \ +# --progress=plain --platform=$platform -t orthancteam/orthanc-runner-base:$BASE_BUILDER_IMAGE_TAG \ +# --build-arg BASE_DEBIAN_IMAGE=$BASE_DEBIAN_IMAGE \ +# $from_cache_arg_runner_base \ +# $to_cache_arg_runner_base \ +# $push_load_arg_builder_image \ +# -f docker/orthanc/Dockerfile.runner-base docker/orthanc + +# ###### builder-base +# docker $build \ +# $add_host_cmd \ +# --progress=plain --platform=$platform -t orthancteam/orthanc-builder-base:$BASE_BUILDER_IMAGE_TAG \ +# $from_cache_arg_builder_base \ +# $to_cache_arg_builder_base \ +# $push_load_arg_builder_image \ +# --build-arg BASE_IMAGE_TAG=$BASE_BUILDER_IMAGE_TAG \ +# -f docker/orthanc/Dockerfile.builder-base docker/orthanc if [[ $image == "full" ]]; then @@ -342,7 +342,8 @@ for target in $buildTargets; do $to_cache_arg \ $push_load_arg_final_image \ $tag_arg \ - --target $target \ - -f docker/orthanc/Dockerfile docker/orthanc/ + # --target $target \ + # -f docker/orthanc/Dockerfile docker/orthanc/ + -f docker/orthanc/AmazonLinux2Dockerfile docker/orthanc/ done