-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (41 loc) · 1.24 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (41 loc) · 1.24 KB
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
50
51
52
53
54
# 🚧 Build stage
FROM rust:slim AS builder
RUN apt-get update && apt-get install -y \
git \
cmake \
clang \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Cargo.toml and Cargo.lock to build dependencies first (for caching)
COPY Cargo.toml Cargo.lock ./
# Create a dummy main.rs to allow dependency compilation
RUN mkdir src && echo "fn main() {}" > src/main.rs
# IMPORTANT: when building relase version of real binary, change "release" to "debug"
RUN cargo build --release && rm -f target/release/deps/reuseport*
COPY src ./src
# build (debug)
RUN cargo build --bin reuseport
# 🧊 Runtime stage
FROM debian:trixie-slim
# runtime tools: curl + bash
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
bash \
lsof \
&& rm -rf /var/lib/apt/lists/*
# binary
COPY --from=builder /app/target/debug/reuseport /usr/local/bin/reuseport
RUN chmod +x /usr/local/bin/reuseport
WORKDIR /app
COPY ./tests/test_reuseport.sh ./tests/test_reuseport.sh
RUN chmod +x tests/test_reuseport.sh
# script'in beklediği binary yolu
ENV REUSEPORT=/usr/local/bin/reuseport
ENV PORT=3000
ENV SKIP_BUILD=1
EXPOSE 3000
STOPSIGNAL SIGTERM
ENTRYPOINT ["tests/test_reuseport.sh"]