Skip to content

Commit

Permalink
Merge pull request DSpace#10081 from tdonohue/fix_docker_build
Browse files Browse the repository at this point in the history
[GitHub Actions] Fix Docker build by exporting local image separate from DockerHub image
  • Loading branch information
tdonohue authored Dec 5, 2024
2 parents 560dae4 + a39c400 commit 16427a5
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/reusable-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,10 @@ jobs:
context: ${{ inputs.dockerfile_context }}
file: ${{ inputs.dockerfile_path }}
platforms: ${{ matrix.arch }}
push: true
# Use tags / labels provided by 'docker/metadata-action' above
tags: ${{ steps.meta_build.outputs.tags }}
labels: ${{ steps.meta_build.outputs.labels }}
# Export image to both Docker registry & to a local TAR file
outputs: |
registry
type=docker,dest=/tmp/${{ inputs.build_id }}.tar
# Upload the local docker image (in TAR file) to a build Artifact
- name: Upload local image to artifact
if: ${{ ! matrix.isPr }}
uses: actions/upload-artifact@v4
with:
name: docker-image-${{ inputs.build_id }}-${{ env.ARCH_NAME }}
path: /tmp/${{ inputs.build_id }}.tar
if-no-files-found: error
retention-days: 1

# Export the digest of Docker build locally (for non PRs only)
- name: Export Docker build digest
Expand All @@ -187,6 +174,32 @@ jobs:
if-no-files-found: error
retention-days: 1

# Build local image (again) and store in a TAR file in /tmp directory
# NOTE: This cannot be combined with push to DockerHub registry above as it's a different type of output.
- name: Build and push image to local image
if: ${{ ! matrix.isPr }}
uses: docker/build-push-action@v5
with:
build-contexts: |
${{ inputs.dockerfile_additional_contexts }}
context: ${{ inputs.dockerfile_context }}
file: ${{ inputs.dockerfile_path }}
platforms: ${{ matrix.arch }}
tags: ${{ steps.meta_build.outputs.tags }}
labels: ${{ steps.meta_build.outputs.labels }}
# Export image to a local TAR file
outputs: type=docker,dest=/tmp/${{ inputs.build_id }}.tar

# Upload the local docker image (in TAR file) to a build Artifact
- name: Upload local image to artifact
if: ${{ ! matrix.isPr }}
uses: actions/upload-artifact@v4
with:
name: docker-image-${{ inputs.build_id }}-${{ env.ARCH_NAME }}
path: /tmp/${{ inputs.build_id }}.tar
if-no-files-found: error
retention-days: 1

# If this build is NOT a PR and passed in a REDEPLOY_SANDBOX_URL secret,
# Then redeploy https://sandbox.dspace.org if this build is for our deployment architecture and 'main' branch.
- name: Redeploy sandbox.dspace.org (based on main branch)
Expand Down

0 comments on commit 16427a5

Please sign in to comment.