quoter/Dockerfile

60 lines
1.2 KiB
Docker
Raw Normal View History

2024-11-13 08:32:50 +00:00
# Build stage
FROM rust:slim-bookworm as build
2024-11-13 06:00:11 +00:00
2024-11-13 08:32:50 +00:00
# Install build dependencies
2024-11-13 07:31:24 +00:00
RUN apt-get update && \
2024-11-13 08:32:50 +00:00
apt-get install -y \
git \
pkg-config \
make \
g++ \
libssl-dev \
libtiff-dev \
clang \
libclang-dev \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Add target
RUN rustup target add x86_64-unknown-linux-gnu
# Create a new empty shell project
2024-08-30 18:05:51 +00:00
RUN USER=root cargo new --bin quoter
2024-11-13 08:32:50 +00:00
2024-08-30 18:05:51 +00:00
WORKDIR /quoter
2023-10-02 11:33:26 +00:00
2024-11-13 08:32:50 +00:00
# Copy manifests
2023-09-27 23:08:48 +00:00
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
2023-10-02 11:33:26 +00:00
2024-11-13 06:08:34 +00:00
# Cache dependencies
2023-09-27 23:08:48 +00:00
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN cargo build --release
2024-11-13 06:08:34 +00:00
# Remove the default source file created by cargo new
2023-09-27 23:08:48 +00:00
RUN rm src/*.rs
2023-10-02 11:33:26 +00:00
2024-11-13 08:32:50 +00:00
# Copy source code
2023-09-27 23:08:48 +00:00
COPY ./src ./src
2023-10-02 11:33:26 +00:00
2024-11-13 08:32:50 +00:00
# Build for release
RUN rm ./target/release/deps/quoter*
2023-09-27 23:08:48 +00:00
RUN cargo build --release
2024-11-13 08:32:50 +00:00
# Final stage
2024-11-13 07:31:24 +00:00
FROM debian:bookworm-slim
2023-09-27 23:08:48 +00:00
2024-11-13 06:08:34 +00:00
# Install runtime dependencies
2024-11-13 07:31:24 +00:00
RUN apt-get update && \
2024-11-13 08:14:53 +00:00
apt-get install -y --no-install-recommends \
libssl3 \
libtiff6 \
2024-11-13 08:32:50 +00:00
&& apt-get clean \
2024-11-13 08:14:53 +00:00
&& rm -rf /var/lib/apt/lists/*
2023-09-27 23:08:48 +00:00
2024-11-13 08:32:50 +00:00
# Copy the build artifact from the build stage
2024-08-30 18:05:51 +00:00
COPY --from=build /quoter/target/release/quoter .
2023-10-11 20:06:27 +00:00
2024-11-13 08:32:50 +00:00
# Set the startup command
2024-11-13 06:08:34 +00:00
CMD ["./quoter"]