lychee/Dockerfile
Matthias 74808d98e6
Cleanup Docker image (#75)
Move `lychee` binary to `/usr/local/bin` to make it callable
without a full path.
This makes it easier to use from the lychee Github action
in the future.
Also the user setup is making things unnecessary complicated
and could be prohibited in some environments so this commit
is removing it and uses the defaults.
2020-12-13 00:43:12 +01:00

32 lines
889 B
Docker

FROM rust:latest as builder
RUN USER=root cargo new --bin lychee
WORKDIR /lychee
# Just copy the Cargo.toml and trigger a build so
# that we compile our dependencies only.
# This way we avoid layer cache invalidation
# if our dependencies haven't changed,
# resulting in faster builds.
COPY Cargo.toml Cargo.toml
RUN cargo build --release
RUN rm src/*.rs
# Copy the source code and run the build again.
# This should only compile lychee itself as the
# dependencies were already built above.
ADD . ./
RUN rm ./target/release/deps/lychee*
RUN cargo build --release
# Our production image starts here, which uses
# the files from the builder image above.
FROM debian:buster-slim
RUN apt-get update \
&& apt-get install -y ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /lychee/target/release/lychee /usr/local/bin/lychee
ENTRYPOINT [ "lychee" ]