-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
48 lines (36 loc) · 1.25 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
FROM rust:1.79 AS builder
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
curl \
unzip \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*
# Install latest protoc
RUN PROTOC_VERSION=$(curl -s https://api.github.com/repos/protocolbuffers/protobuf/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') && \
PROTOC_VERSION=${PROTOC_VERSION#v} && \
curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" && \
unzip "protoc-${PROTOC_VERSION}-linux-x86_64.zip" -d /usr/local && \
rm "protoc-${PROTOC_VERSION}-linux-x86_64.zip"
# Copy manifests and build only the dependencies to cache them
RUN USER=root cargo new --bin shreds
WORKDIR /shreds
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN cargo build --release
RUN rm src/*.rs
# Copy over source
COPY ./src ./src
# Build for release
RUN cargo build --release
FROM ubuntu:22.04 AS runner
RUN apt-get update && apt-get install -y \
ca-certificates \
openssl \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /shreds/target/release/shreds .
EXPOSE 8001/udp
CMD ["./shreds", "--bind", "0.0.0.0:8001"]