2024-11-03 20:09:41 -08:00
|
|
|
################
|
|
|
|
|
##### Builder
|
2026-09-12 13:26:59 -07:00
|
|
|
FROM rust:1.98.1-slim AS builder
|
2024-11-03 20:09:41 -08:00
|
|
|
|
|
|
|
|
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
|
2026-09-12 13:26:59 -07:00
|
|
|
FROM alpine:3.24.1 AS runtime
|
2024-11-03 20:09:41 -08:00
|
|
|
|
|
|
|
|
# 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"]
|