feat(build): add Docker support for emailks service
- Create multi-stage Dockerfile with builder and runtime stages - Add .dockerignore to exclude unnecessary files and directories - Configure builder stage with Rust toolchain and dependencies - Set up runtime stage with minimal Debian base image - Copy compiled binary from builder to runtime stage - Expose port 50051 for gRPC service - Add proper dependency caching for faster builds - Include SSL certificates and required libraries in runtime
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
target/
|
||||
.git/
|
||||
.idea/
|
||||
**/*.md
|
||||
+38
@@ -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"]
|
||||
Reference in New Issue
Block a user