-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
178b142
commit be2e6b0
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Stage 1: Base compiler image with necessary dependencies | ||
FROM rust:1.81.0-slim-bullseye AS base | ||
|
||
# Install cargo-chef for dependency caching | ||
RUN cargo install cargo-chef | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Stage 2: Planner (generating the recipe) | ||
FROM base AS planner | ||
|
||
# Copy only Cargo files to cache dependencies | ||
COPY Cargo.toml Cargo.lock ./ | ||
|
||
# Prepare the recipe for caching dependencies (Cargo.toml/Cargo.lock) | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
# Stage 3: Builder with necessary dependencies for OpenSSL | ||
FROM base AS builder | ||
|
||
# Install required dependencies for building Rust projects (OpenSSL, pkg-config) | ||
RUN apt-get update && apt-get install -y \ | ||
pkg-config \ | ||
libssl-dev \ | ||
build-essential \ | ||
protobuf-compiler | ||
|
||
# Copy the generated recipe from the planner stage | ||
COPY --from=planner /app/recipe.json recipe.json | ||
|
||
# Cache the dependencies using the cargo-chef recipe | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
# Copy the source code and build the project | ||
COPY . . | ||
RUN cargo build --release | ||
|
||
# Stage 4: Final runtime image (lean image) | ||
FROM debian:bullseye-slim AS runtime | ||
|
||
# Set the working directory for the final container | ||
WORKDIR /usr/local/bin | ||
|
||
# Install necessary runtime dependencies (OpenSSL and CA certificates) | ||
RUN apt-get update && apt-get install -y \ | ||
libssl-dev \ | ||
ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the compiled binary from the builder stage | ||
COPY --from=builder /app/target/release/bolt /usr/local/bin/bolt | ||
|
||
# Define the entrypoint for the container | ||
ENTRYPOINT ["/usr/local/bin/bolt"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[toolchain] | ||
channel = "1.81.0" | ||
profile = "default" |