lychee/Dockerfile

42 lines
1.4 KiB
Docker
Raw Normal View History

FROM rust:bookworm as builder
2020-12-02 22:43:05 +00:00
RUN USER=root cargo new --bin lychee
WORKDIR /lychee
# Just copy the Cargo.toml files and trigger
2021-04-15 00:36:01 +00:00
# a build so that we compile our dependencies only.
2020-12-02 22:43:05 +00:00
# This way we avoid layer cache invalidation
# if our dependencies haven't changed,
# resulting in faster builds.
2021-04-15 00:36:01 +00:00
COPY lychee-bin/Cargo.toml lychee-bin/Cargo.toml
COPY lychee-lib/Cargo.toml lychee-lib/Cargo.toml
RUN cargo build --release \
&& rm src/*.rs
2020-12-02 22:43:05 +00:00
# Copy the source code and run the build again.
# This should only compile lychee itself as the
# dependencies were already built above.
COPY . ./
RUN rm ./target/release/deps/lychee* \
&& cargo build --release \
&& strip target/release/lychee
2020-12-02 22:43:05 +00:00
# Our production image starts here, which uses
2020-12-02 22:43:05 +00:00
# the files from the builder image above.
FROM debian:bookworm-slim
2020-12-02 22:43:05 +00:00
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
--no-install-recommends ca-certificates tzdata \
&& rm -rf /var/cache/debconf/* \
# Clean and keep the image small. This should not
# be necessary as the debian-slim images have an
# auto clean mechanism but we may rely on other
# images in the future (see:
# https://github.com/debuerreotype/debuerreotype/blob/master/scripts/debuerreotype-minimizing-config).
&& apt-get clean \
2020-12-02 22:43:05 +00:00
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /lychee/target/release/lychee /usr/local/bin/lychee
ENTRYPOINT [ "lychee" ]