49 lines
1.1 KiB
Docker
49 lines
1.1 KiB
Docker
# Use a specific Rust version that is compatible with your dependencies
|
|
FROM rust:alpine AS build
|
|
|
|
# Print system information for debugging
|
|
RUN uname -a
|
|
RUN cat /etc/os-release
|
|
|
|
# Install necessary packages
|
|
RUN apk update && \
|
|
apk add git pkgconf make g++ openssl libheif libheif-dev tiff tiff-dev && \
|
|
rustup target add x86_64-unknown-linux-gnu
|
|
|
|
# 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 a minimal runtime image for the final stage
|
|
FROM alpine:latest
|
|
|
|
ENV RUST_BACKTRACE=full
|
|
ENV RUST_LOG=warn
|
|
|
|
# Install runtime dependencies
|
|
RUN apk update && apk add --no-cache openssl libheif tiff
|
|
|
|
# Copy the compiled binary from the build stage
|
|
COPY --from=build /quoter/target/release/quoter .
|
|
|
|
ENV PORT=8080
|
|
EXPOSE 8080
|
|
|
|
CMD ["./quoter"] |