quoter/Dockerfile
Untone 0982dff45b
Some checks failed
deploy / deploy (push) Failing after 5s
heic-bypass
2024-11-13 12:03:32 +03:00

70 lines
1.4 KiB
Docker

# Build stage
FROM rust:slim-bookworm AS build
# Install build dependencies
RUN apt-get update && \
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
RUN USER=root cargo new --bin quoter
WORKDIR /quoter
# Copy manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
# Cache dependencies
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN cargo build --release
# Remove the default source file created by cargo new
RUN rm src/*.rs
# Copy source code
COPY ./src ./src
# Build for release
RUN rm ./target/release/deps/quoter*
RUN cargo build --release
# Final stage
FROM debian:bookworm-slim
# Install runtime dependencies and CA certificates
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
libssl3 \
libtiff6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& update-ca-certificates
# Set environment variables
ENV RUST_BACKTRACE=1
ENV RUST_LOG=warn
# Copy the build artifact from the build stage
COPY --from=build /quoter/target/release/quoter .
# Create healthcheck
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:8080/ || exit 1
# Set the startup command
CMD ["./quoter"]