-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,55 @@ | ||
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef | ||
# --- Cargo Chef Stage (for caching dependencies) --- | ||
FROM rust:1.78.0-bookworm as chef | ||
WORKDIR /app | ||
|
||
FROM chef AS planner | ||
RUN cargo install cargo-chef | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build dependencies - this is the caching Docker layer! | ||
# --- Dependency Caching Stage --- | ||
FROM chef as cache | ||
WORKDIR /app | ||
|
||
RUN apt-get update -y && apt-get install -y \ | ||
libssl-dev \ | ||
ca-certificates \ | ||
libudev-dev \ | ||
libusb-1.0-0-dev \ | ||
pkg-config \ | ||
libudev-dev \ | ||
build-essential | ||
|
||
COPY --from=chef /app/recipe.json recipe.json | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
# Build application | ||
|
||
# --- Application Build Stage --- | ||
FROM cache as builder | ||
WORKDIR /app | ||
RUN apt-get update -y && apt-get install -y \ | ||
libssl-dev \ | ||
ca-certificates \ | ||
libudev-dev \ | ||
libusb-1.0-0-dev \ | ||
pkg-config \ | ||
libudev-dev \ | ||
build-essential | ||
COPY . . | ||
RUN cargo build --release --bin devhub-cache-api | ||
COPY --from=cache /app/target target | ||
ENV SQLX_OFFLINE=true | ||
RUN cargo build --release | ||
|
||
# We do not need the Rust toolchain to run the binary! | ||
FROM debian:bookworm-slim AS runtime | ||
# --- Final Stage with Minimal Base Image --- | ||
FROM debian:bookworm-slim | ||
RUN apt-get update -y && apt-get install -y \ | ||
libssl-dev \ | ||
ca-certificates \ | ||
libudev-dev \ | ||
libusb-1.0-0-dev \ | ||
pkg-config \ | ||
libudev-dev \ | ||
build-essential | ||
RUN useradd -ms /bin/bash app | ||
USER app | ||
WORKDIR /app | ||
COPY --from=builder /app/target/release/devhub-cache-api /usr/local/bin | ||
ENTRYPOINT ["/usr/local/bin/devhub-cache-api"] | ||
COPY --from=builder /app/target/release/devhub-cache-api . | ||
EXPOSE 8000 | ||
CMD ["./devhub-cache-api"] |