-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move to ghcr registry #382
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright the Hyperledger Blockchain Explorer contributors. All rights reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Build docker image | ||
|
||
on: | ||
workflow_dispatch: # workflow_dispatch must be enabled in main branch to support release action on older release branches | ||
create: | ||
tags: | ||
- v* | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "Dockerfile" | ||
- "postgres-Dockerfile" | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
# on tag vx.y.z created, create docker tag x.y.z | ||
build-and-push-docker-release: | ||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- dockerfile: ./Dockerfile | ||
component: explorer | ||
- dockerfile: ./postgres-Dockerfile | ||
component: explorer-db | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
buildkitd-flags: --debug | ||
config-inline: | | ||
[worker.oci] | ||
max-parallelism = 1 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.component }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}}.{{minor}}.{{patch}} | ||
|
||
- name: Login to the container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push ${{ matrix.component }} Image | ||
id: push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ${{ matrix.dockerfile }} | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @adityajoshi12 , As per yesterdays (23Aug2023) discussion on this PR, the image build should be triggered only whenever a new release happens(build-and-push-docker-release).
Please look into this and make changes accordingly. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two flow in this CI, one is(L62) when anything pushed to the main branch container images will be created with the latest tag, while the other flow(L84) will be invoked on the creation of tags and new container images will be created based on the tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, as per the first workflow the image gets created whenever the code is pushed to main branch. As per discussion conclusion yesterday, the build image should happen whenever we create a new release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I understood that, but does that mean we will not have images with latest tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can run the two workflows. With the first workflow, we would have the images with the latest tag and with the second work flow will have the images with the release tag. However the first - workflow shouldn't be triggered on every push to main. @adityajoshi12 @arsulegai @vineeth2328 Please suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have a seperate branch
dev
and all the new commit/PR can be merged to that branch (dev) and after sometime we can merge the dev branch to the main branch. And image with tag latest can be build with main branchThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree @ArchanaArige , for the time being, let us have a human triggered workflow for the
latest
tag image creation. Re: Branching strategy, Manoj (mentee) is experimenting something similar and listing down advantages/disadvantages in terms of maintainability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will discuss about this one in the next call and make a decision. There are some other dependency PRs, once they are merged, then we can go ahead and merge this one too.