-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It *dramatically* reduces the amount of time it takes to re-run image building if the set of packages used hasn't changed. It's hard to get an objective measurement (because we do get *some* caching from being careful what we add), but: On my machine, for a rebuild after a change in 'pkg/api', it reduces `make docker-build` time from 249s -> 22s. And, it also slightly improves the time it takes to run a clean build. After `docker system prune -af`, it reduces `make docker-build` on my machine from 345s -> 126s.
- Loading branch information
Showing
8 changed files
with
101 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Base image for go dependencies, to speed up builds when they haven't changed. | ||
# For more, see https://github.com/neondatabase/go-chef | ||
FROM golang:1.23-alpine AS chef | ||
|
||
ARG GO_CHEF_VERSION=v0.1.0 | ||
RUN go install github.com/neondatabase/go-chef@$GO_CHEF_VERSION | ||
WORKDIR /workspace | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
# Produce a "recipe" containing information about all the packages imported. | ||
# This step is usually NOT cached, but because the recipe is usually the same, follow-up steps | ||
# usually WILL be cached. | ||
RUN go-chef --prepare recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /workspace/recipe.json recipe.json | ||
# Compile the dependencies baesd on the "recipe" alone -- usually cached. | ||
RUN CGO_ENABLED=0 go-chef --cook recipe.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters