-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
42 lines (30 loc) · 1.19 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
FROM rust:1-buster as sysstat
WORKDIR /sysstat
RUN git clone https://github.com/sysstat/sysstat /sysstat
RUN CFLAGS=-static ./configure && CFLAGS=-static make -j$(nproc)
RUN wc -c /sysstat/iostat | numfmt --to=iec-i
FROM rust:1-buster as build
# create dummy application for dependency caching
RUN USER=root cargo new --bin throttled
WORKDIR /throttled
RUN rustup toolchain install nightly
# download + compile dependencies for caching
COPY Cargo.toml Cargo.lock ./
RUN cargo +nightly build --release
RUN rm src/*.rs
# build for real
COPY src ./src
RUN rm ./target/release/deps/throttled*
RUN cargo +nightly build --release
RUN wc -c target/release/throttled | numfmt --to=iec-i
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
# FROM amd64/busybox:uclibc as busybox
# FROM gcr.io/distroless/cc:debug
# COPY --from=busybox /bin/busybox /busybox/busybox
# RUN ["/busybox/busybox", "--install", "/bin"]
FROM gcr.io/distroless/cc:latest
COPY --from=build /throttled/target/release/throttled .
COPY --from=sysstat /sysstat/iostat /sysstat/iostat
CMD ["/usr/local/bin/throttled"]