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 image builds with Docker cache mounts #995

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ on:
- pyproject.toml
# And when we change this workflow itself...
- .github/workflows/build-docker.yml
# Or when we change the Dockerfile!
- Dockerfile

jobs:
docker-publish:
Expand Down
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ RUN rustup target add $(cat rust_target.txt)
COPY crates crates
COPY ./Cargo.toml Cargo.toml
COPY ./Cargo.lock Cargo.lock
RUN cargo zigbuild --bin puffin --target $(cat rust_target.txt) --release
RUN cp target/$(cat rust_target.txt)/release/puffin /puffin

# Build with mounted cache
RUN --mount=type=cache,target=./target \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo zigbuild --bin puffin --target $(cat rust_target.txt) --release

# Copy binary into normal layer
RUN --mount=type=cache,target=./target \
cp ./target/$(cat rust_target.txt)/release/puffin /puffin

# TODO(konsti): Optimize binary size, with a version that also works when cross compiling
# RUN strip --strip-all /puffin

Expand Down
2 changes: 1 addition & 1 deletion crates/puffin-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub enum BuildKind {
impl Display for BuildKind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
BuildKind::Wheel => f.write_str("wheel"),
BuildKind::Wheel => f.write_str("REVERT ME"),
BuildKind::Editable => f.write_str("editable"),
}
}
Expand Down
Loading