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

🏃 speed up e2e image builds #2660

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ scripts/
tilt-settings.json
tilt.d/
Tiltfile
**/.tiltbuild
test/infrastructure/docker/e2e/logs/**
**/config/**/*.yaml
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't think we need anything under the config directory, or is this to prevent accidental inclusion of other directories that might be named config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, maybe deserves a comment – the trouble is that setting the image pull strategy + arch modifies files under each manager's config directory.

So, when we do the next COPY . . it's a different tree, and the go build . runs again, once per manager.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the point I was attempting to make is that I don't think we need the config directory at all in the docker images, since it only contains generated yaml and not code to be compiled/run in the container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly – it's not needed by any of the images, but it does bust the cache on each image build. Seemed like a worthy .dockerignore entry :)

_artifacts
6 changes: 3 additions & 3 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ FROM gcr.io/distroless/base:debug as tilt
WORKDIR /
COPY --from=tilt-helper /start.sh .
COPY --from=tilt-helper /restart.sh .
COPY .tiltbuild/manager .
COPY manager .
"""

# Configures a provider by doing the following:
Expand Down Expand Up @@ -160,11 +160,11 @@ def enable_provider(name):
# build into the container.
docker_build(
ref = p.get("image"),
context = context,
context = context + "/.tiltbuild/",
dockerfile_contents = dockerfile_contents,
target = "tilt",
entrypoint = ["sh", "/start.sh", "/manager"],
only = ".tiltbuild/manager",
only = "manager",
live_update = [
sync(context + "/.tiltbuild/manager", "/manager"),
run("sh /restart.sh"),
Expand Down
14 changes: 14 additions & 0 deletions test/infrastructure/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ FROM golang:1.13.8 as builder
ARG goproxy=https://proxy.golang.org
ENV GOPROXY=$goproxy

WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum

# Essentially, change directories into CAPD
WORKDIR /workspace/test/infrastructure/docker
# Copy the Go Modules manifests
COPY test/infrastructure/docker/go.mod go.mod
COPY test/infrastructure/docker/go.sum go.sum

# Cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# This needs to build with the entire Cluster API context
WORKDIR /workspace
# Copy in cluster-api (which includes the test/infrastructure/docker subdirectory)
Expand Down