From 11304b3c3ad1b8e949606ee6fdff56203f4f47dc Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Thu, 27 Jan 2022 11:37:46 +0100 Subject: :zap: Change build-target to musl, and use scratch as base-image for final image --- Dockerfile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 3f33149..454a759 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,25 @@ FROM rust:1.58 as builder +# Install and configure dependencies needed for building for musl target +RUN rustup target add x86_64-unknown-linux-musl +RUN apt update && apt install -y musl-tools musl-dev +RUN update-ca-certificates + +# Add source code to image WORKDIR /usr/src/rss-watcher COPY . . -RUN cargo install --path . +# Build +RUN cargo build --target x86_64-unknown-linux-musl --release + +# Move to a smaller image +FROM scratch + +# Copy binary from builder +COPY --from=builder /usr/src/rss-watcher/target/x86_64-unknown-linux-musl/release/rss-watcher /rss-watcher -#FROM debian:buster-slim -#RUN apt-get update \ -# && apt-get install -y libssl-dev libc-bin libc6 \ -# && rm -rf /var/lib/apt/lists/* -#COPY --from=builder /usr/local/cargo/bin/rss-watcher /usr/local/bin/rss-watcher -#ENV RUST_LOG=info +# Add log level info, if we don't do this, no logs will be written +ENV RUST_LOG=info -CMD ["rss-watcher"] +# Start target +CMD ["/rss-watcher"] -- cgit v1.2.3