Skip to content

Commit 31b043d

Browse files
authored
Merge pull request #1549 from rust-lang/ci-cache
Optimize Dockerfile to speed up CI caching
2 parents fc55ec2 + 885ce01 commit 31b043d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ jobs:
2323
- name: Formatting check
2424
run: cargo fmt --all -- --check
2525

26-
- name: Test and build
27-
run: docker build -t rustc-perf .
26+
- uses: docker/setup-buildx-action@v2
27+
- name: Build and push
28+
uses: docker/build-push-action@v4
29+
with:
30+
context: .
31+
tags: rustc-perf
32+
cache-from: type=gha
33+
cache-to: type=gha,mode=max
2834

2935
- name: Deploy to production
3036
uses: rust-lang/simpleinfra/github-actions/upload-docker-image@master

Dockerfile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
FROM node:18 as frontend
22

3-
COPY ./site ./site
3+
COPY ./site/frontend ./site/frontend
44
RUN cd site/frontend && npm ci
55
RUN cd site/frontend && npm run check
66
RUN cd site/frontend && npm run build
77

8-
FROM ubuntu:20.04 as build
8+
FROM ubuntu:20.04 as base
9+
10+
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
911

1012
RUN apt-get update -y && \
1113
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -23,6 +25,17 @@ RUN apt-get update -y && \
2325
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
2426
--default-toolchain stable --profile minimal -y
2527

28+
RUN bash -c 'source $HOME/.cargo/env && cargo install cargo-chef'
29+
30+
FROM base AS planner
31+
COPY . .
32+
RUN bash -c 'source $HOME/.cargo/env && cargo chef prepare --recipe-path recipe.json'
33+
34+
FROM base as build
35+
COPY --from=planner recipe.json recipe.json
36+
37+
RUN bash -c 'source $HOME/.cargo/env && cargo chef cook --release --recipe-path recipe.json'
38+
2639
COPY ./Cargo.lock ./Cargo.lock
2740
COPY ./Cargo.toml ./Cargo.toml
2841
COPY ./collector ./collector

0 commit comments

Comments
 (0)