Skip to content
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

feat(gha): add docker push github action #1116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgettica
Copy link

fixes #427

@georgettica
Copy link
Author

this is not tested fully, but I am hopeful this just works.

@georgettica
Copy link
Author

@epage , this is my "throw this and check if it sticks"

I added the manual trigger if you want to play with it manually, before pushing to continuus-deployment

if you want me to integrate with other github actions I can spend time on this too

@epage
Copy link
Collaborator

epage commented Oct 8, 2024

As this is a completely new workflow to me, posting an Action is insufficient. I specifically asked for documentation. I need to understand the workflow and the requirements it places on me.


steps:
- name: Checkout code
uses: actions/checkout@v4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only fetch 1 depth is sufficient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not find a way to change it to the way you want. I saw the default fetch-depth is 1

Comment on lines +42 to +47
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.get_tag.outputs.tag }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to build multi-architecture images alongside the CLI release

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ill do it along the weekend 🍾

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my weekend was not very useful, so found time to push this now

@georgettica
Copy link
Author

oh sorry @epage , I will create the documentation on how this workflow works in addition to the changes requested in the review

@georgettica
Copy link
Author

georgettica commented Oct 14, 2024

@weijiany care to check on your machine?

docker build --tag typos --platform "linux/arm64/v8,linux/amd64" .

( I use podman so I just replaced it with docker hoping it just works )

@georgettica georgettica requested a review from weijiany October 14, 2024 17:55
Dockerfile Show resolved Hide resolved
@georgettica
Copy link
Author

It is worth noting ChatGPT is a good friend of mine, so he is a co-author.

I hope this is ok by you ❤️

@weijiany
Copy link

@weijiany care to check on your machine?

docker build --tag typos --platform "linux/arm64/v8,linux/amd64,linux/amd64" .

( I use podman to I just replaced it with docker hoping it just works )

Hi @georgettica, it works well. ✅

BTW, I am not the repository's maintainer; I am simply a user who wishes to directly utilize the image.

tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.get_tag.outputs.tag }}
# platforms: linux/arm64/v8,darwin/amd64,linux/amd64,windows/amd64,linux/amd64 # was what I was aiming for
# but locally I only got to these 3 (specifically linux/arm64/v8 but yeah)
platforms: linux/arm64,linux/amd64

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I didn't work with on Github action to build multi-arch. But in some pipeline tool that I have used, a question is needn't we to install qemu before building image?’

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I can add it, but I am adding the required tools inside the docker, so I hope it "just works".

@georgettica
Copy link
Author

PS, I accidentally had one of the tools twice: linux/amd64,linux/amd64 but it isn't a real issue

@georgettica
Copy link
Author

@weijiany, I guess the only other thing I want to ask so we can move this PR forward is your thoughts and opinions on the documentation I cobbled up.

@weijiany
Copy link

@weijiany, I guess the only other thing I want to ask so we can move this PR forward is your thoughts and opinions on the documentation I cobbled up.

For me, the doc is quite clear, possibly because I've reviewed your changes by going through the GitHub Actions documentation. 😅

@georgettica
Copy link
Author

Well, at least it's clear. I hope it'll be ok once the actual review comes around

@georgettica
Copy link
Author

@epage, can I get 👀 ? (sorry for pinging, I don't want this PR to go to waste)

@epage
Copy link
Collaborator

epage commented Oct 21, 2024

You are in my queue of prs and issues to get to.

Be sure the commits are all atomic and organized for how you want me to review and merge this.

@georgettica georgettica force-pushed the georgettica/feat/gha/add-docker-push-github-action branch 2 times, most recently from 91f9eb2 to 0a1a113 Compare October 22, 2024 16:28
@georgettica
Copy link
Author

I made them into one big blob, as they weren't atomic and some were patch fixes.

I am ok with all the PR not passing as it's one atomic change.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11464483713

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 22.789%

Totals Coverage Status
Change from base Build 11432065555: 0.0%
Covered Lines: 536
Relevant Lines: 2352

💛 - Coveralls

@mjpieters
Copy link

I'm looking forward to this landing, because that'd make it much, much easier to install typos into our dev docker containers!

COPY --from=ghcr.io/crate-ci/typos:latest /typos /bin/

instead of installingcargo-binstall then cargo-binstall typos, which can run into Github API rate limits quite quickly on a CI.

I see your commit message failed the linter; should be easy to fix:

git commit --amend --message 'feat(gha): Add docker push github action'
git force --push

@georgettica georgettica force-pushed the georgettica/feat/gha/add-docker-push-github-action branch from 0a1a113 to f629cac Compare October 27, 2024 19:05
@georgettica
Copy link
Author

took me a while, but let's hope this passes 🤞

@georgettica
Copy link
Author

@mjpieters I would be really happy if this works, lets see though

Comment on lines +4 to +5
release:
types: [published]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building of binaries is kicked off from a tag, rather than release. Should we do that here as well?

name: post-release
on:
push:
tags:
- "v*.*.*"
- "!varcon*"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be done, for sure!

id: get_tag
run: |
if [ "${{ github.event_name }}" == "release" ]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this off of a tag, could we simplify this to

run: echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll do that too

Comment on lines +48 to +50
# platforms: linux/arm64/v8,darwin/amd64,linux/amd64,windows/amd64,linux/amd64 # was what I was aiming for
# but locally I only got to these 3 (specifically linux/arm64/v8 but yeah)
platforms: linux/arm64,linux/amd64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a during-development note and I'd like it resolved one way or the other

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PC is MacOS, so I don't have much wiggle room for testing.

I would give it a go if I had more computers with different platforms.

@@ -1,11 +1,82 @@
ARG DEBIAN_DIST=bullseye
# syntax=docker/dockerfile:1.10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a complete rewrite of the dockerfile

Can any of this be broken out into smaller (complete) steps (ie commits) to make this easier to follow along?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can do that, sorry for the mess. This process is more complex for me so I opted to give one big commit and break it into tiny bits if required (mostly because my work was based inside.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage you are correct, but the reason I did this is to allow compiling the code to multiple architectures based on TARGETPLATFORM arg (filled by the --platform flag in docker build)

@@ -0,0 +1,219 @@
# Build and Push Docker Image Workflow Documentation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I said that I wanted it documented, I meant a write up in the issue or PR so I could understand the expectations behind this. Unsure how much of this will be useful in a living document. If there is, it likely more belongs in CONTRIBUTING.md

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I will move it there, as moving documentation is easier than rewriting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the understanding from #1116 (comment), I don't think we need to keep this documentation.

Comment on lines +139 to +140
- **GitHub Permissions**: The `GITHUB_TOKEN` provided by GitHub Actions must have the necessary permissions (default settings typically suffice).
- **Understanding of Docker and GHCR**: Basic knowledge of Docker image building and pushing to GHCR will be beneficial.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the core of what I was wanting to understand.

If I get the gist of it, instead of us pushing to docker hub, we are pushing to github's container registry which allows us to just use GH_TOKEN without having to setup any count, register secrets, and/or do any manual per-release action.

Is that right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that is the gist.

I think GH_TOKEN is if you run it manually, so most times the action won't need even permissions to run.

@georgettica
Copy link
Author

Worth noting to all I am not quick with PR modifications, but I hope this will soon go through another cycle (and I will ping all of you when it is)

@georgettica
Copy link
Author

seems this PR is getting a lot of traction and I am not getting enough time to sit on it.

if anyone wants to grab what I have so far and push it across the finish line be my guest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not available dockerhub/external repo for dockerfile
5 participants