28 lines
639 B
Docker
28 lines
639 B
Docker
FROM rust:1.80-slim AS builder
|
|
|
|
# Dummy app
|
|
RUN USER=root cargo new --bin app
|
|
WORKDIR /app
|
|
|
|
# Cargo build and src cleaup
|
|
COPY ./Cargo.toml ./Cargo.toml
|
|
COPY ./Cargo.lock ./Cargo.lock
|
|
RUN cargo build --release
|
|
RUN rm src/*.rs
|
|
|
|
# Copy src files
|
|
COPY ./src ./src
|
|
RUN rm ./target/release/deps/app*
|
|
RUN cargo build --release
|
|
|
|
|
|
FROM debian:bookworm-slim
|
|
|
|
# Install necessary runtime libraries
|
|
RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy the binary from the builder stage
|
|
COPY --from=builder /app/target/release/app /usr/local/bin/app
|
|
|
|
# Set execution permissions and run
|
|
CMD ["app"] |