Add Dockerfile.

This commit is contained in:
Bauke 2022-10-06 17:09:46 +02:00
parent 0914392b3e
commit 163502505a
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 25 additions and 0 deletions

25
Dockerfile Normal file
View File

@ -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"]