From ff9176a9cc862e718ef8f31a5500486ff15f9355 Mon Sep 17 00:00:00 2001 From: Vitaly _Vi Shukela Date: Mon, 16 May 2022 00:33:44 +0300 Subject: [PATCH] Improve Dockerfile: * No Cargo.lock or cruft in build directory * More default Cargo features with overriding option * Strip executable --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c966761..e58b889 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,14 +6,16 @@ RUN apk add --no-cache musl-dev pkgconfig openssl-dev WORKDIR /src/websocat COPY Cargo.toml Cargo.toml +ARG CARGO_OPTS="--features=workaround1,seqpacket,prometheus_peer,prometheus/process,crypto_peer" RUN mkdir src/ &&\ echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \ - cargo build --release --target=x86_64-unknown-linux-musl && \ + cargo build --release --target=x86_64-unknown-linux-musl $CARGO_OPTS && \ rm -f target/x86_64-unknown-linux-musl/release/deps/websocat* -COPY . . -RUN cargo build --release --target=x86_64-unknown-linux-musl +COPY src src +RUN cargo build --release --target=x86_64-unknown-linux-musl $CARGO_OPTS && \ + strip target/x86_64-unknown-linux-musl/release/websocat # Final stage FROM alpine:3.15