mirror of
https://github.com/stalwartlabs/stalwart.git
synced 2026-03-17 14:34:03 +00:00
53 lines
1.9 KiB
Docker
53 lines
1.9 KiB
Docker
FROM debian:trixie-slim AS chef
|
|
RUN apt-get update && \
|
|
export DEBIAN_FRONTEND=noninteractive && \
|
|
apt-get install -yq \
|
|
build-essential \
|
|
cmake \
|
|
clang \
|
|
curl \
|
|
protobuf-compiler \
|
|
adduser
|
|
ENV RUSTUP_HOME=/opt/rust/rustup \
|
|
PATH=/home/root/.cargo/bin:/opt/rust/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
RUN curl https://sh.rustup.rs -sSf | \
|
|
env CARGO_HOME=/opt/rust/cargo \
|
|
sh -s -- -y --default-toolchain stable --profile minimal --no-modify-path && \
|
|
env CARGO_HOME=/opt/rust/cargo \
|
|
rustup component add rustfmt
|
|
RUN curl -LO https://github.com/apple/foundationdb/releases/download/7.3.69/foundationdb-clients_7.3.69-1_amd64.deb && \
|
|
dpkg -i foundationdb-clients_7.3.69-1_amd64.deb
|
|
RUN env CARGO_HOME=/opt/rust/cargo cargo install cargo-chef && \
|
|
rm -rf /opt/rust/cargo/registry/
|
|
WORKDIR /app
|
|
|
|
FROM chef AS planner
|
|
COPY Cargo.toml .
|
|
COPY Cargo.lock .
|
|
COPY crates/ crates/
|
|
COPY resources/ resources/
|
|
COPY tests/ tests/
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
FROM chef AS builder
|
|
COPY --from=planner /app/recipe.json recipe.json
|
|
RUN cargo chef cook --release --recipe-path recipe.json
|
|
COPY Cargo.toml .
|
|
COPY Cargo.lock .
|
|
COPY crates/ crates/
|
|
COPY resources/ resources/
|
|
COPY tests/ tests/
|
|
RUN cargo build -p stalwart --no-default-features --features "foundationdb elastic s3 redis azure nats enterprise" --release
|
|
|
|
FROM debian:trixie-slim AS runtime
|
|
|
|
COPY --from=builder /app/target/release/stalwart /usr/local/bin/stalwart
|
|
RUN apt-get update -y && apt-get install -yq --no-install-recommends ca-certificates curl adduser
|
|
RUN curl -LO https://github.com/apple/foundationdb/releases/download/7.3.69/foundationdb-clients_7.3.69-1_amd64.deb && \
|
|
dpkg -i foundationdb-clients_7.3.69-1_amd64.deb
|
|
RUN useradd stalwart -s /sbin/nologin -M
|
|
RUN mkdir -p /opt/stalwart
|
|
RUN chown stalwart:stalwart /opt/stalwart
|
|
|
|
ENTRYPOINT ["/usr/local/bin/stalwart", "--config", "/opt/stalwart/etc/config.toml"]
|