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

Docker+CI: More efficient build #939

Closed
wants to merge 3 commits into from

Conversation

julienduchesne
Copy link
Member

@julienduchesne julienduchesne commented Oct 27, 2023

CI was moved to GHA here: #938

However, it turns out that buildx is pretty slow when building across other archs. Improvements in this PR:

  • Remove apk add curl where easily doable
  • Download jb from Github releases rather than building it
  • Build tk exec outside of Docker
  • Bonus: Set paths filter for docs build

Result: 1.5m runtime rather than 10+m

CI was moved to GHA here: #938
However, it turns out that `buildx` is pretty slow. Improvements in this PR:
- Remove `apk add curl` where easily doable
- Download `jb` from Github releases rather than building it
- Build `tk` exec outside of Docker
@julienduchesne julienduchesne requested a review from a team October 27, 2023 17:09
@julienduchesne julienduchesne marked this pull request as ready for review October 27, 2023 17:11
@github-actions
Copy link

PR Preview Action v1.4.4
🚀 Deployed preview to https://grafana.github.io/tanka/pr-preview/pr-939/
on branch gh-pages at 2023-10-27 17:12 UTC

Comment on lines +49 to +52
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.20'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.20'
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

Copy link
Contributor

Choose a reason for hiding this comment

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

The downside of this approach is that there is now a place for specifying the Go version that is not updated by dependabot. Should we perhaps update the Makefile to read the Go version from the Dockerfile or something like that?

@@ -1,21 +1,17 @@
# download kubectl
FROM golang:1.21.3-alpine as kubectl
RUN apk add --no-cache curl
FROM golang:1.21.3 as kubectl
Copy link
Member

Choose a reason for hiding this comment

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

Since none of these stages are building code any more, you could drop the golang images altogether

Comment on lines -42 to -45
FROM golang:1.21.3 as build
WORKDIR /app
COPY . .
RUN make static
Copy link
Member

Choose a reason for hiding this comment

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

Be nicer if this could be kept, so a docker build continues to work as expected and isn't a two-step thing where if you forget to run make static you can get an outdated binary in the image.

It should be possible to do this with make, since it can avoid rebuilding the target if the inputs haven't changed. Would require a change in Makefile to list the dependencies (*.go, go.mod and go.sum) but shouldn't be too bad to do.

@julienduchesne
Copy link
Member Author

Will close this PR as I do not have the time/desire to get it fixed (repo isn't broken, it's just slightly slow). Pick it up if you wish

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.

None yet

3 participants