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

Build improvements #1200

Merged
merged 5 commits into from
Oct 14, 2019
Merged

Build improvements #1200

merged 5 commits into from
Oct 14, 2019

Conversation

errordeveloper
Copy link
Contributor

@errordeveloper errordeveloper commented Aug 27, 2019

Description

Basic summary:

See proposal document within for more details.

Checklist

  • Code compiles correctly (i.e make build)
  • All unit tests passing (i.e. make test)
  • Manually tested

@errordeveloper errordeveloper force-pushed the build-improvements branch 2 times, most recently from aaa14ea to 51db528 Compare August 27, 2019 08:26
Dockerfile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@errordeveloper errordeveloper force-pushed the build-improvements branch 8 times, most recently from 44e48cf to c8fb446 Compare August 28, 2019 10:48
@errordeveloper errordeveloper marked this pull request as ready for review August 28, 2019 10:49
@errordeveloper errordeveloper force-pushed the build-improvements branch 3 times, most recently from da359e4 to 1539c6a Compare September 5, 2019 16:47
Makefile Outdated Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@errordeveloper errordeveloper force-pushed the build-improvements branch 6 times, most recently from 3245ea3 to 8a09d0a Compare September 6, 2019 16:19
@gemagomez
Copy link

I have a more generic question for the analysis doc. When you separate build from test, how are you going to know that you are testing the right image when it comes to downloading it and testing?

@errordeveloper
Copy link
Contributor Author

errordeveloper commented Sep 10, 2019

I have a more generic question for the analysis doc. When you separate build from test, how are you going to know that you are testing the right image when it comes to downloading it and testing?

It's configured explicitly in the CircleCI config at the moment, and for any given revision it can be determined based on git tree hashes. You can read Makefile.docker to find out how it works, if comments are not clear there - please let me know, I'm not very keen on duplicating the details in another file. In short, we have .build_image_manifest that tracks git tree hashes of each of the files that determine what goes into an image, that file is checked in and we use git ls-tree --full-tree @ -- .build_image_manifest to get the git tree hash of that file and use that as image tag.
So, given image tag you can use git show to find out what was in .build_image_manifest, and use git show again for each of the hashes that file returns.

E.g. given weaveworks/eksctl-build:b0aa27c30e3f533cdc861a471a0f01f624c7f3d5:

$ git show b0aa27c30e3f533cdc861a471a0f01f624c7f3d5
100644 blob 47cb6bf90db7b43772d0a77f4082d8552d0724fc    Dockerfile
100644 blob 5a627d2f0babe888166ab54168f5d11cdaa11f8e    go.mod
100644 blob 68e10db9f70d4e1d0e0159dba3cdb57669be64c0    go.sum
100755 blob 180a7df24779458c0bb748261c6dc4ed78185c86    install-build-deps.sh
$ git show 47cb6bf90db7b43772d0a77f4082d8552d0724fc | head -5
# Make sure to run the following commands after changes to this file are made:
# `make -f Makefile.docker update-build-image-manifest && make -f Makefile.docker push-build-image`

# This digest corresponds to golang:1.12.9-alpine3.10
FROM golang@sha256:e0660b4f1e68e0d408420acb874b396fc6dd25e7c1d03ad36e7d6d1155a4dff6 AS base
$

This explicitly precludes that image was built and published before tests run, which was already required previously, but not explicitly.

@errordeveloper
Copy link
Contributor Author

cc @stefanprodan

@errordeveloper errordeveloper force-pushed the build-improvements branch 2 times, most recently from a9e8c18 to 937bc39 Compare September 19, 2019 14:06
@errordeveloper
Copy link
Contributor Author

@marccarre I've updated the proposal doc, and rebased this - could you please take another look?

@errordeveloper errordeveloper removed the request for review from 2opremio September 19, 2019 14:07
@errordeveloper errordeveloper changed the title WIP: Build improvements Build improvements Sep 19, 2019
@errordeveloper errordeveloper force-pushed the build-improvements branch 5 times, most recently from 37e523a to cb7c7b1 Compare October 11, 2019 14:17
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: docker://weaveworks/eksctl-build:19ff80e010d2fdb7be3c44fc6491e13395a682ad
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do you know if there is a way to factorise docker://weaveworks/eksctl-build:19ff80e010d2fdb7be3c44fc6491e13395a682ad?

Copy link
Contributor Author

@errordeveloper errordeveloper Oct 14, 2019

Choose a reason for hiding this comment

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

Not sure. For now make -f Makefile.docker update-build-image-manifest handles updating it here and in .circleci/config.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of the fields in github configs accept shell syntax (like foo-$(echo 123)), but that didn't work here.

GO_VERSION: 1.12.6
GOCACHE: /home/circleci/.cache/go-build/
GOPATH: /home/circleci/go
BUILD_IMAGE: weaveworks/eksctl-build:19ff80e010d2fdb7be3c44fc6491e13395a682ad
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do you know if there is a way to factorise BUILD_IMAGE: weaveworks/eksctl-build:19ff80e010d2fdb7be3c44fc6491e13395a682ad in order to have it defined at a higher-level in the YAML file?

@marccarre
Copy link
Contributor

This looks reasonable to me. The only way is forward. And we can always refine later.

@errordeveloper errordeveloper mentioned this pull request Oct 14, 2019
3 tasks
- remove `.dockerignore` file
- isolate context to speed-up `docker build`
- tag build image and intermediate container automatically
- use more cosistent lower-case variable variable names
- make `git diff` error hint fixes
- split base build image
  - includes Docker CLI
  - use it in Circle CI
- there is no need to build the image in CI as a primary job
  - pulling the image is as quick as restoring cache
  - we can control what is being cached
  - we don't have to rely on how CircleCI cache works, so our
    jobs are more portable
- cleanup
  - remove outdated Skaffold config
  - cleanup Dockerfile, cache all of the modules, use GOPROXY
- upgrade CircleCI jobs' resource class
- start trial of GitHub Actions in parallel to CircleCI
  - start with two workflows
    - one is for running tests & building the binaries in pre-existing image
    - one for updating images
- split Docker-related targets from the main Makefile, avoiding
  having to have Go installed in CI job that builds images
- extract common variables into separate `Makefile.common`
- update modules that are used in the build
- fix file license header filename
@errordeveloper errordeveloper merged commit f978a03 into master Oct 14, 2019
@errordeveloper errordeveloper deleted the build-improvements branch October 14, 2019 14:25
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.

build cache misses automate tagging of build image
4 participants