-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
30 lines (20 loc) · 880 Bytes
/
Dockerfile
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
30
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM rust:1.68 as build
ARG TARGETARCH
RUN echo "export PATH=/usr/local/cargo/bin:$PATH" >> /etc/profile
WORKDIR /app
COPY ["./build/platform.sh", "./"]
RUN ./platform.sh
COPY ["./build/.cargo/config", ".cargo/config"]
RUN rustup target add $(cat /.platform)
RUN apt-get update && apt-get install -y $(cat /.compiler)
COPY ["./metrics/Cargo.toml", "./metrics/Cargo.lock", "./"]
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release --target=$(cat /.platform)
COPY ["./metrics/src", "./src"]
RUN touch src/main.rs && cargo build --release --target=$(cat /.platform)
RUN mkdir -p /release/$TARGETARCH
RUN cp ./target/$(cat /.platform)/release/metrics /release/$TARGETARCH/metrics
FROM gcr.io/distroless/cc-debian11
ARG TARGETARCH
COPY --from=build /release/$TARGETARCH/metrics /
CMD ["/metrics"]