Skip to content

Commit

Permalink
image build: layer caching
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Sep 26, 2023
1 parent 5f07f49 commit 22a84c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
with:
image: limitador
tags: ${{ env.IMG_TAGS }}
layers: true
platforms: linux/amd64,linux/arm64
dockerfiles: |
./Dockerfile
Expand Down
22 changes: 21 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,31 @@ RUN PKGS="gcc-c++ gcc-toolset-12-binutils-gold openssl-devel protobuf-c protobuf
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path --profile minimal --default-toolchain ${RUSTC_VERSION} -c rustfmt -y

WORKDIR /usr/src/limitador

ARG GITHUB_SHA
ENV GITHUB_SHA=${GITHUB_SHA:-unknown}
ENV RUSTFLAGS="-C target-feature=-crt-static"

COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

COPY limitador/Cargo.toml ./limitador/Cargo.toml
COPY limitador-server/Cargo.toml ./limitador-server/Cargo.toml

RUN mkdir -p limitador/src limitador-server/src

RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > limitador/src/main.rs \
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > limitador-server/src/main.rs

RUN source $HOME/.cargo/env \
&& cargo build --release

# avoid downloading and compiling all the dependencies when there's a change in
# our code.
RUN ls target
RUN ls target/release
RUN ls target/release/deps
RUN rm -f target/release/limitador*

COPY . .

RUN source $HOME/.cargo/env \
Expand Down

0 comments on commit 22a84c8

Please sign in to comment.