Skip to content

Commit

Permalink
use local-build.sh instead
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed Jan 29, 2025
1 parent e362d72 commit dd1ace3
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 65 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/civ2.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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/<repo name>" --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
72 changes: 31 additions & 41 deletions backup_.github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
name: Build Image and Push to Registries

on: push

on:
workflow_call:
inputs:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
4 changes: 1 addition & 3 deletions bash-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
43 changes: 22 additions & 21 deletions local-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit dd1ace3

Please sign in to comment.