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

caching of dependencies from a private registry #296

Open
Vsev0l0d opened this issue Jan 22, 2025 · 0 comments
Open

caching of dependencies from a private registry #296

Vsev0l0d opened this issue Jan 22, 2025 · 0 comments

Comments

@Vsev0l0d
Copy link

Cargo chef speeds up the build very well, but I noticed that packages from the private registry are downloaded again every time. Is it possible to configure their caching too?

18:46:46  #18 [builder 5/7] RUN mold -run cargo chef cook --verbose --release --recipe-path recipe.json
18:46:46  #18 0.508     Updating crates.io index
18:46:46  #18 0.837     Updating `kc_rs_private` index
18:46:51  #18 4.346  Downloading crates ...
18:46:51  #18 4.571   Downloaded kc_grpc v0.0.8 (registry `kc_rs_private`)
18:46:51  #18 4.853   Downloaded kc_nlp_grpc v0.0.2 (registry `kc_rs_private`)
18:46:51  #18 4.901   Downloaded amq-protocol v7.2.2
...

Dockerfile

FROM  harbor.com/infra/cargo-chef:0.1.66-rust-1.78-slim-bookworm AS chef

WORKDIR /app

FROM chef AS planner
COPY . .

ARG CARGO_REGISTRY_DEFAULT_ARG
ENV CARGO_REGISTRY_DEFAULT=$CARGO_REGISTRY_DEFAULT_ARG
ARG CARGO_REGISTRIES_KC_RS_PRIVATE_INDEX_ARG
ENV CARGO_REGISTRIES_KC_RS_PRIVATE_INDEX=$CARGO_REGISTRIES_KC_RS_PRIVATE_INDEX_ARG
ARG CARGO_REGISTRIES_KC_RS_PRIVATE_TOKEN_ARG
ENV CARGO_REGISTRIES_KC_RS_PRIVATE_TOKEN=$CARGO_REGISTRIES_KC_RS_PRIVATE_TOKEN_ARG

RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/deployments/app/install_latest_protoc.sh .

RUN apt-get update \
    && apt-get install --no-install-recommends -y \
    curl \
    unzip \
    pkg-config \
    libssl-dev \
    clang \
    git \
    mold \
    && bash -ue ./install_latest_protoc.sh \
    && rm -rf /var/lib/apt/lists/*

COPY --from=planner /app/recipe.json recipe.json


ARG CARGO_REGISTRY_DEFAULT_ARG
ENV CARGO_REGISTRY_DEFAULT=$CARGO_REGISTRY_DEFAULT_ARG
ARG CARGO_REGISTRIES_KC_RS_PRIVATE_INDEX_ARG
ENV CARGO_REGISTRIES_KC_RS_PRIVATE_INDEX=$CARGO_REGISTRIES_KC_RS_PRIVATE_INDEX_ARG
ARG CARGO_REGISTRIES_KC_RS_PRIVATE_TOKEN_ARG
ENV CARGO_REGISTRIES_KC_RS_PRIVATE_TOKEN=$CARGO_REGISTRIES_KC_RS_PRIVATE_TOKEN_ARG
ARG CARGO_BUILD_JOBS_ARG=default
ENV CARGO_BUILD_JOBS=$CARGO_BUILD_JOBS_ARG

RUN mold -run cargo chef cook --verbose --release --recipe-path recipe.json
...

.cargo/config.toml

[registry]
default = "kc_rs_private"

[registries.kc_rs_private]
index = "sparse+https://my-artifactory.com/artifactory/api/cargo/kc-rust-back-cargo-local/index/"
token = "Bearer xxxxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant