-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
49 lines (36 loc) · 1.13 KB
/
Dockerfile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
# First stage: Build the server
FROM rust:1.78.0 AS builder
# Set the working directory
WORKDIR /app
# Install dependencies for buf and protoc
RUN apt-get update && apt-get install -y \
curl \
unzip \
protobuf-compiler \
build-essential
# Install buf (latest release)
RUN curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v1.36.0/buf-Linux-x86_64" \
-o /usr/local/bin/buf && \
chmod +x /usr/local/bin/buf
# Copy the proto crate
COPY ./proto ./proto
COPY ./db ./db
# Set working directory to the server crate
WORKDIR /app/server
# Copy the entire server project
COPY ./server ./
RUN rustup target add x86_64-unknown-linux-gnu
# Build the release binary for linux/amd64/v3
RUN cargo build --release --target x86_64-unknown-linux-gnu
# Second stage: Create the final image for server
FROM rust:1.78.0-slim AS final
RUN apt-get update && apt-get install -y \
libpq5
# Copy the built binary from the builder stage
COPY --from=builder /app/server/target/x86_64-unknown-linux-gnu/release/server /usr/local/bin/server
# Expose the REST and gRPC ports
EXPOSE 3000
EXPOSE 50051
# Run the server
CMD ["server"]