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

image build: layer caching #217

Closed
wants to merge 2 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
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
2 changes: 1 addition & 1 deletion limitador-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ fn create_config() -> (Configuration, &'static str) {
config::env::REDIS_LOCAL_CACHE_FLUSHING_PERIOD_MS.unwrap_or("1000"),
)
.display_order(4)
.help("Flushing period for counters in milliseconds"),
.help("Flushing period for counters in milliseconds change"),
)
.arg(
Arg::new("max")
Expand Down