forked from oxidar-org/rust-grpc-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (24 loc) · 970 Bytes
/
Dockerfile
File metadata and controls
36 lines (24 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ---- Build Stage ----
FROM rustlang/rust:nightly as builder
WORKDIR /app
# Install build dependencies for static linking and protoc
RUN apt-get update && apt-get install -y musl-tools pkg-config libssl-dev protobuf-compiler
# Add musl target
RUN rustup target add x86_64-unknown-linux-musl
# Copy source and build
COPY . .
# Build for musl target
RUN cargo build --release --target x86_64-unknown-linux-musl
# ---- Runtime Stage ----
FROM debian:bookworm-slim
# Install only necessary runtime dependencies
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the statically built binary from the builder stage
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/grpc_sample /app/server
# Cloud Run expects the app to listen on $PORT (default 8080)
ENV PORT=8080
# Expose the port (for documentation; Cloud Run maps ports automatically)
EXPOSE 8080
# Start the server
CMD ["/app/server"]