diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ccc277e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +target/ +.git/ +.idea/ +**/*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..649a53a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# ---- builder ---- +FROM rust:1.96-slim-bookworm AS builder + +RUN apt-get update && apt-get install -y --no-install-recommends \ + pkg-config \ + libssl-dev \ + protobuf-compiler \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +# Cache dependencies +COPY Cargo.toml Cargo.lock ./ +COPY build.rs ./ +COPY proto/ proto/ +RUN echo '' >lib.rs && \ + echo 'fn main() {}' >main.rs && \ + cargo build --release; \ + rm -f lib.rs main.rs + +# Build real binary +COPY . . +RUN cargo build --release --bin emailks && \ + cp target/release/emailks /app/emailks + +# ---- runtime ---- +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + libssl3 \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /app/emailks /usr/local/bin/emailks + +EXPOSE 50051 + +ENTRYPOINT ["emailks"]