FROM rust:1.82-alpine3.20 AS builder
WORKDIR /usr/src/correlate
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
COPY . .
# Build with or without database support based on ARG
ARG WITH_DATABASE=true
RUN --mount=type=cache,target=./build/target \
--mount=type=cache,target=./build/cargo/registry \
--mount=type=cache,target=./build/cargo/git \
apk add libc-dev pkgconfig libressl-dev
RUN if [ "$WITH_DATABASE" = "true" ]; then \
echo "Building with database support" && \
cargo build --release; \
else \
echo "Building without database support" && \
cargo build --release --no-default-features; \
fi
FROM alpine:3.20
LABEL dev.orbitsolutions.code="ORB IT Solutions LLC"
LABEL org.opencontainers.image.authors="orbit+maint@orbitsolutions.dev"
LABEL version="1.0"
ENV OPENSMTPD_VER="7.5.0p0"
RUN apk add --no-cache -t opensmtpd-rundeps tzdata \
"opensmtpd~${OPENSMTPD_VER}"; \
mkdir -p /var/spool/smtpd && chmod 711 /var/spool/smtpd
COPY --from=builder /usr/src/correlate/target/release/correlate /usr/local/bin/correlate
ENV CORRELATE_EMAIL_RECIPIENT=""
ENV CORRELATE_EMAIL_SENDER=""
# Optional database configuration (only used when built with database support)
ENV CORRELATE_DATABASES=""
EXPOSE 25 8000
CMD ["/bin/sh", "-c", "smtpd -v; correlate"]