2024-04-12 22:35:00 +08:00
|
|
|
# Stalwart Dockerfile
|
|
|
|
# Credits: https://github.com/33KK
|
2023-07-11 23:16:08 +08:00
|
|
|
|
2024-04-12 22:35:00 +08:00
|
|
|
FROM --platform=$BUILDPLATFORM docker.io/lukemathwalker/cargo-chef:latest-rust-slim-bookworm AS chef
|
|
|
|
WORKDIR /build
|
2023-07-11 23:16:08 +08:00
|
|
|
|
2024-04-12 22:35:00 +08:00
|
|
|
FROM --platform=$BUILDPLATFORM chef AS planner
|
|
|
|
COPY . .
|
|
|
|
RUN cargo chef prepare --recipe-path /recipe.json
|
2023-07-23 14:43:04 +08:00
|
|
|
|
2024-04-12 22:35:00 +08:00
|
|
|
FROM --platform=$BUILDPLATFORM chef AS builder
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
RUN case "${TARGETPLATFORM}" in \
|
|
|
|
"linux/arm64") echo "aarch64-unknown-linux-gnu" > /target.txt && echo "-C linker=aarch64-linux-gnu-gcc" > /flags.txt ;; \
|
|
|
|
"linux/amd64") echo "x86_64-unknown-linux-gnu" > /target.txt && echo "-C linker=x86_64-linux-gnu-gcc" > /flags.txt ;; \
|
|
|
|
*) exit 1 ;; \
|
|
|
|
esac
|
|
|
|
RUN export DEBIAN_FRONTEND=noninteractive && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -yq build-essential libclang-16-dev \
|
|
|
|
g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \
|
|
|
|
g++-x86-64-linux-gnu binutils-x86-64-linux-gnu
|
|
|
|
RUN rustup target add "$(cat /target.txt)"
|
|
|
|
COPY --from=planner /recipe.json /recipe.json
|
|
|
|
RUN RUSTFLAGS="$(cat /flags.txt)" cargo chef cook --target "$(cat /target.txt)" --release --recipe-path /recipe.json
|
|
|
|
COPY . .
|
|
|
|
RUN RUSTFLAGS="$(cat /flags.txt)" cargo build --target "$(cat /target.txt)" --release -p mail-server -p stalwart-cli
|
|
|
|
RUN mv "/build/target/$(cat /target.txt)/release" "/output"
|
2023-07-11 23:16:08 +08:00
|
|
|
|
2024-04-12 22:35:00 +08:00
|
|
|
FROM docker.io/debian:bookworm-slim
|
|
|
|
WORKDIR /opt/stalwart-mail
|
|
|
|
RUN export DEBIAN_FRONTEND=noninteractive && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -yq ca-certificates
|
|
|
|
COPY --from=builder /output/stalwart-mail /usr/local/bin
|
|
|
|
COPY --from=builder /output/stalwart-cli /usr/local/bin
|
|
|
|
COPY ./resources/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
|
|
RUN chmod -R 755 /usr/local/bin
|
|
|
|
CMD ["/usr/local/bin/stalwart-mail"]
|
2023-07-28 02:18:34 +08:00
|
|
|
VOLUME [ "/opt/stalwart-mail" ]
|
2024-04-07 23:20:50 +08:00
|
|
|
EXPOSE 443 25 587 465 143 993 4190 8080
|
2023-07-22 19:08:08 +08:00
|
|
|
ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
|