quoter/Dockerfile
Untone ab98010224
Some checks failed
deploy / deploy (push) Failing after 5s
heic-clang-debian
2024-11-13 10:31:24 +03:00

52 lines
1.3 KiB
Docker

# Use Debian-based Rust image instead of Alpine
FROM rust:slim-bookworm AS build
# Install necessary packages
RUN apt-get update && \
apt-get install -y git pkg-config make g++ libssl-dev libheif-dev libtiff-dev \
clang libclang-dev && \
rustup target add x86_64-unknown-linux-gnu
# Set environment variables for libclang
ENV LIBCLANG_PATH=/usr/lib/llvm-14/lib
ENV BINDGEN_EXTRA_CLANG_ARGS="-I/usr/include"
# Create a new Rust binary project
RUN USER=root cargo new --bin quoter
WORKDIR /quoter
# Copy Cargo files to cache dependencies
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 your source code into the container
COPY ./src ./src
# Build the application for release
RUN cargo build --release
# Use Debian slim for the final stage
FROM debian:bookworm-slim
ENV RUST_BACKTRACE=full
ENV RUST_LOG=warn
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends libssl3 libheif1 libtiff5 && \
rm -rf /var/lib/apt/lists/*
# Copy the compiled binary from the build stage
COPY --from=build /quoter/target/release/quoter .
ENV PORT=8080
EXPOSE 8080
CMD ["./quoter"]