2022-10-06 15:09:46 +00:00
|
|
|
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
|
|
|
|
|
2022-10-06 17:29:40 +00:00
|
|
|
# Copy the configuration files and build in release, caching the dependencies.
|
|
|
|
COPY Cargo.lock Cargo.toml askama.toml .
|
2022-10-06 15:09:46 +00:00
|
|
|
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
|
2022-10-09 12:04:41 +00:00
|
|
|
COPY node_modules/modern-normalize node_modules/modern-normalize
|
2022-10-06 15:09:46 +00:00
|
|
|
|
|
|
|
# Remove the cached tildes-statistics dependencies.
|
|
|
|
RUN rm target/release/deps/tildes_statistics*
|
|
|
|
|
|
|
|
# Build the executable with actual source code.
|
2022-10-10 11:46:23 +00:00
|
|
|
RUN cargo install --offline --path .
|
2022-10-06 15:09:46 +00:00
|
|
|
|
|
|
|
# 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"]
|