30 lines
801 B
Docker
30 lines
801 B
Docker
################
|
|
##### Builder
|
|
FROM rust:1.92.0-slim AS builder
|
|
|
|
WORKDIR /usr/src
|
|
|
|
COPY . /usr/src
|
|
|
|
## Install target platform (Cross-Compilation) --> Needed for Alpine
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
|
|
|
# This is a dummy build to get the dependencies cached.
|
|
RUN cargo build --target x86_64-unknown-linux-musl --release
|
|
|
|
## Touch main.rs to prevent cached release build
|
|
RUN touch /usr/src/server/src/main.rs
|
|
|
|
# This is the actual application build.
|
|
RUN cargo build --package server --target x86_64-unknown-linux-musl --release
|
|
|
|
################
|
|
##### Runtime
|
|
FROM alpine:3.23.3 AS runtime
|
|
|
|
# Copy application binary from builder image
|
|
COPY --from=builder /usr/src/target/x86_64-unknown-linux-musl/release/saslauthd /usr/local/bin
|
|
|
|
|
|
# Run the application
|
|
CMD ["/usr/local/bin/saslauthd"] |