forked from suse-edge/akri-mqtt-discovery-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.discovery-handler
29 lines (28 loc) · 1.08 KB
/
Dockerfile.discovery-handler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ARG RUST_VERSION=1.73.0
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION} as build
RUN apt-get update && \
apt-get install -y --no-install-recommends protobuf-compiler
ARG TARGETPLATFORM RUST_VERSION
RUN case "$TARGETPLATFORM" in \
"linux/arm/v7") echo "armv7-unknown-linux-gnueabihf";; \
"linux/arm64") echo "aarch64-unknown-linux-gnu";; \
"linux/amd64") echo "x86_64-unknown-linux-gnu";; \
*) exit 1;; \
esac > /rust_target
RUN rustup target add --toolchain $RUST_VERSION $(cat /rust_target)
RUN rustup component add rustfmt --toolchain $RUST_VERSION
RUN USER=root cargo new --bin dh
WORKDIR /dh
COPY ./Cargo.toml ./Cargo.toml
RUN cargo build --release && \
rm ./src/*.rs && \
DEP_PATH=`echo "./target/release/deps/mqtt-discovery-handler*" | tr - _` && \
rm $DEP_PATH
COPY ./src ./src
RUN cargo build --release
FROM debian:buster-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends libssl-dev && \
apt-get clean
COPY --from=build /dh/target/release/mqtt-discovery-handler /mqtt-discovery-handler
ENTRYPOINT ["/mqtt-discovery-handler"]