Skip to content

Commit

Permalink
Improve Dockerfile:
Browse files Browse the repository at this point in the history
* No Cargo.lock or cruft in build directory
* More default Cargo features with overriding option
* Strip executable
  • Loading branch information
vi committed May 15, 2022
1 parent 09aca88 commit ff9176a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff9176a

Please sign in to comment.