-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
48 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,49 @@ | ||
FROM alpine | ||
ARG BUILDER_VERSION=1.0.0 | ||
|
||
# Configure base image with buildtime dependencies. | ||
FROM econialabs/rust-builder:$BUILDER_VERSION AS base | ||
WORKDIR /app | ||
RUN mkdir foo | ||
|
||
# Prepare build recipe. | ||
FROM base AS planner | ||
COPY . . | ||
RUN cargo chef prepare --bin broker | ||
|
||
# Cache build dependencies, compile binary. | ||
FROM base AS builder | ||
ARG FEATURES | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libudev-dev=252.* \ | ||
build-essential=12.* \ | ||
libclang-dev=1:14.* \ | ||
libpq-dev=15.* \ | ||
libssl-dev=3.* \ | ||
libdw-dev=0.188-2.1 \ | ||
pkg-config=1.8.* \ | ||
lld=1:14.* \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
COPY --from=planner app/recipe.json recipe.json | ||
RUN ls -la | ||
COPY processor processor | ||
RUN cargo chef cook \ | ||
--bin broker \ | ||
--features $FEATURES \ | ||
--package broker \ | ||
--release | ||
COPY . . | ||
RUN cargo build --bin broker --package broker --release --features $FEATURES | ||
|
||
# Install runtime dependencies, copy over binary. | ||
FROM debian:bookworm-slim AS runtime | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
curl=7.* \ | ||
libssl-dev=3.* \ | ||
libpq-dev=15.* \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& mkdir app | ||
COPY --from=builder /app/target/release/broker /app | ||
|
||
# This helps the container stop faster. | ||
STOPSIGNAL SIGKILL | ||
|
||
ENTRYPOINT ["/app/broker"] |