slim-buster2

This commit is contained in:
Untone 2024-11-13 09:08:34 +03:00
parent 2979146b34
commit 956468b0c8

View File

@ -1,43 +1,52 @@
FROM rust:slim-buster AS build # Use a specific Rust version that is compatible with your dependencies
FROM rust:1.81-slim-buster AS build
# Print system information for debugging
RUN uname -a RUN uname -a
RUN cat /etc/os-release # print ubuntu version RUN cat /etc/os-release
# had to add this for open-ssl # Install necessary packages
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install -y git pkg-config make g++ libssl-dev wget \ apt-get install -y git pkg-config make g++ libssl-dev wget \
libheif-dev libtiff-dev libtiff5-dev && \ libheif-dev libtiff-dev && \
rustup target add x86_64-unknown-linux-gnu rustup target add x86_64-unknown-linux-gnu
# Create a new Rust binary project
RUN USER=root cargo new --bin quoter RUN USER=root cargo new --bin quoter
WORKDIR /quoter WORKDIR /quoter
# Copy Cargo files to cache dependencies
COPY ./Cargo.lock ./Cargo.lock COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml COPY ./Cargo.toml ./Cargo.toml
# cache dependencies # Cache dependencies
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN cargo build --release RUN cargo build --release
# Remove the default source file created by cargo new
RUN rm src/*.rs RUN rm src/*.rs
# copy your source tree # Copy your source code into the container
COPY ./src ./src COPY ./src ./src
# build for release # Build the application for release
RUN rm ./target/release/deps/quoter*
RUN cargo build --release RUN cargo build --release
FROM rust:slim-buster # Use a minimal runtime image for the final stage
FROM debian:buster-slim
ENV RUST_BACKTRACE=full ENV RUST_BACKTRACE=full
ENV RUST_LOG=warn ENV RUST_LOG=warn
RUN apt-get update && apt install -y openssl libssl-dev \ # Install runtime dependencies
libheif1 libtiff5 RUN apt-get update && apt-get install -y openssl libssl-dev \
libheif1 libtiff5 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy the compiled binary from the build stage
COPY --from=build /quoter/target/release/quoter . COPY --from=build /quoter/target/release/quoter .
ENV PORT=8080 ENV PORT=8080
EXPOSE 8080 EXPOSE 8080
CMD ["./quoter"] CMD ["./quoter"]