diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..159e3eb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# Stage 1: Build the rust binary +FROM rust:1.80-slim-bookworm AS builder + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + pkg-config \ + libssl-dev \ + protobuf-compiler \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src/app + +# Option: Copy in root workspace files and source crates +COPY . . + +# Build only the server for release +RUN cargo build --release --bin furumi-server + +# Stage 2: Create the minimal runtime image +FROM debian:bookworm-slim + +# Install system dependencies needed at runtime (like OpenSSL if dynamically linked) +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +# Create a non-root user +RUN useradd -ms /bin/bash appuser +WORKDIR /home/appuser + +# Copy the binary from the builder stage +COPY --from=builder /usr/src/app/target/release/furumi-server /usr/local/bin/furumi-server + +USER appuser + +# Expose ports: 50051 (gRPC) and 9090 (Metrics) +EXPOSE 50051 +EXPOSE 9090 + +# Command to run the server +ENTRYPOINT ["furumi-server"]