From 163502505a1e62ef85b1abe8618955983b2d2bbd Mon Sep 17 00:00:00 2001 From: Bauke Date: Thu, 6 Oct 2022 17:09:46 +0200 Subject: [PATCH] Add Dockerfile. --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c4a28e9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM rust:1.64 as builder + +# Create a new empty project. +RUN USER=root cargo new --bin tildes-statistics +WORKDIR /tildes-statistics +RUN mv src source + +# Copy the Cargo files and build in release, caching the dependencies. +COPY Cargo.* . +RUN cargo build --release + +# Then copy our code. This way when only the source code changes, the +# dependencies don't have to be entirely rebuilt. +COPY source source + +# Remove the cached tildes-statistics dependencies. +RUN rm target/release/deps/tildes_statistics* + +# Build the executable with actual source code. +RUN cargo install --path . + +# Copy the executable to a smaller final image. +FROM debian:bullseye-slim +COPY --from=builder /usr/local/cargo/bin/tildes-statistics /usr/local/bin +CMD ["tildes-statistics"]