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: add docker image on release and master #135

Merged
merged 6 commits into from
Apr 1, 2021

Conversation

anthonymq
Copy link
Contributor

What does this do / why do we need it?

It release a docker image for every release. I needed it in my Gitlab-ci to easily generate my changelog.

How this PR fixes the problem?

It builds and push an image to Dockerhub.

What should your reviewer look out for in this PR?

The dockerfile and the github actions files

Check lists

  • Test passed
  • Coding style (indentation, etc)

Additional Comments (if any)

You will need to create two secrets on the repo to authenticate to Dockerhub

Which issue(s) does this PR fix?

fixes #132

@anthonymq
Copy link
Contributor Author

@khos2ow here is the PR 😆

Copy link
Collaborator

@khos2ow khos2ow left a comment

Choose a reason for hiding this comment

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

Thank you @anthonymq, please see my comments below.

.github/workflows/release.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
.goreleaser.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
.github/workflows/docker.yml Outdated Show resolved Hide resolved
@khos2ow khos2ow added the type: enhancement New enhancement label Mar 31, 2021
@anthonymq anthonymq requested a review from khos2ow March 31, 2021 19:33
Copy link
Collaborator

@khos2ow khos2ow left a comment

Choose a reason for hiding this comment

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

Thank you @anthonymq for the awesome work, functionality wise it's finished and /lgtm. But the only remaining open question is where to push the images:

  1. GitHub Packages or
  2. quay.io

/cc @clok @mavogel

@khos2ow khos2ow requested a review from clok March 31, 2021 19:40
@khos2ow
Copy link
Collaborator

khos2ow commented Mar 31, 2021

@anthonymq in the meantime please add a new section in Installation guide as well, until we hear back from folks.

@coveralls
Copy link

coveralls commented Mar 31, 2021

Pull Request Test Coverage Report for Build 708956705

  • 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 76.76%

Totals Coverage Status
Change from base Build 705687175: 0.0%
Covered Lines: 1843
Relevant Lines: 2401

💛 - Coveralls

@clok
Copy link
Collaborator

clok commented Apr 1, 2021

This is great work! Thank you 🥇

Before I weigh in on which registry I would recommend, I am doing some local testing with GH Registry. Should be able to weigh in today.

Copy link
Collaborator

@clok clok left a comment

Choose a reason for hiding this comment

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

After playing with GH Container Registry, I really like it. That said, it does pose a particular hurdle for this project as we would need to get @wadackel to enable the feature on the Organization before we can push. While not the biggest hurdle, it is one that we do not have a timeline on.

I went ahead and created a quay.io org and repo for this project. I added notes inline where we will need to update to point to the correct registry.

I also added a bot user to the Quay org and update the Repo secrets with the credentials.

Again, awesome work!

.github/workflows/publish.yml Outdated Show resolved Hide resolved
.github/workflows/publish.yml Outdated Show resolved Hide resolved
.github/workflows/publish.yml Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
.goreleaser.yml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
RUN apk add --no-cache git && \
mkdir /workdir

COPY git-chglog /usr/local/bin/git-chglog
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want to note that this works due to a "side effect" that we (and goreleaser) run make build on a 64-bit version of Linux. As a result, we can use the make build command outside of the container and then COPY it into the alpine image, 💥 it works.

A use case to consider: If a user attempts to build the image locally on a Mac or Windows host, the resulting docker image will throw a runtime error due to an incompatible architecture.

If we wanted to be pedantic, we could make a target that specifically calls out that we are creating the binary for the purpose of using within an apline image.

alpine: clean
    env GOOS=linux GARCH=amd64 CGO_ENABLED=0 go build -ldflags=$(LDFLAGS) -o git-chglog ./cmd/git-chglog
	
docker: alpine
    docker build --tag quay.io/git-chglog/git-chglog:local .

Just something to consider.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This, actually, was the main motivation for me on Makefile refactoring, because I was trying to test this locally and noticed make build doesn't statically build the binary which has been modified since.

That said in the snippet above alpine is not necessarily needed, but docker is very nice to have and very convenient. 👍

Copy link
Contributor Author

@anthonymq anthonymq Apr 1, 2021

Choose a reason for hiding this comment

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

Are you okay with ?

docker: build  
    docker build --tag git-chglog .

It will be easier to use locally and i could leverage that on the CI

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right on. If we wanted to ensure that the GOHOST values are correct for binary used with the the docker target, what process do you suggest?

The make alpine was just an attempt to encapsulate the generation of the binary used in the docker image. Is there a set of parameters we could pass to make docker that would not require the alpine target? The modifications that first come to mind are adding a build step to the make docker target, but that is just the "hammer sees nail" solution 🤣

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks better IMO (somewhere in Build section of Makefile):

.PHONY: docker
docker: DOCKER_TAG ?= dev
docker: build   ## Build Docker image
	@ $(MAKE) --no-print-directory log-$@
	docker build --pull --tag quay.io/git-chglog/git-chglog:$(DOCKER_TAG) .

and then you can update publish.yml accordingly: DOCKER_TAG=edge make docker

Copy link
Collaborator

@clok clok left a comment

Choose a reason for hiding this comment

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

Great job @anthonymq on this. Really appreciate you working with us on this.

@khos2ow do you feel the discussion we are having regarding make docker is a blocker for merging this PR as is? I am okay with separating that out to a chore PR after this.

We maintain the following tags:
- `edge`: Image that is build from the current `HEAD` of the main line branch.
- `latest`: Image that is built from the [latest released version](https://github.com/git-chglog/git-chglog/releases)
- `x.y.y` (versions): Images that are build from the tagged versions within Github.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch

RUN apk add --no-cache git && \
mkdir /workdir

COPY git-chglog /usr/local/bin/git-chglog
Copy link
Collaborator

Choose a reason for hiding this comment

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

Right on. If we wanted to ensure that the GOHOST values are correct for binary used with the the docker target, what process do you suggest?

The make alpine was just an attempt to encapsulate the generation of the binary used in the docker image. Is there a set of parameters we could pass to make docker that would not require the alpine target? The modifications that first come to mind are adding a build step to the make docker target, but that is just the "hammer sees nail" solution 🤣

@khos2ow
Copy link
Collaborator

khos2ow commented Apr 1, 2021

@clok no it's not a blocker, but I wanted to make sure everything is ready before we merge, and I also wanted to backport older images to quay because it has a weird thing about history. So I want to manually build and push old tags and then merge this one which will update edge. Can you add me @khos2ow to org you created on quay?

@clok
Copy link
Collaborator

clok commented Apr 1, 2021

@clok no it's not a blocker, but I wanted to make sure everything is ready before we merge, and I also wanted to backport older images to quay because it has a weird thing about history. So I want to manually build and push old tags and then merge this one which will update edge. Can you add me @khos2ow to org you created on quay?

Done. That would be awesome to backport the images. Let's break out the Makefile changes into a chore PR. This is ready to 🤘

@clok clok merged commit 2307bff into git-chglog:master Apr 1, 2021
@clok
Copy link
Collaborator

clok commented Apr 1, 2021

@khos2ow @anthonymq Added #137 as a follow up on this.

@khos2ow khos2ow mentioned this pull request Apr 1, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate a docker image for every release
4 participants