59 lines
1.6 KiB
Docker
59 lines
1.6 KiB
Docker
# Multi-stage Dockerfile for Nym localnet
|
|
# Stage 1: Build binaries
|
|
# Stage 2: Slim runtime with only the final binaries
|
|
|
|
# --- Build stage ---
|
|
FROM rust:latest AS builder
|
|
|
|
WORKDIR /usr/src/nym
|
|
COPY ./ ./
|
|
|
|
ENV CARGO_BUILD_JOBS=8
|
|
|
|
RUN cargo build --release --locked -p nym-node --features otel && \
|
|
cargo build --release --locked -p nym-network-requester -p nym-socks5-client
|
|
|
|
# --- Runtime stage ---
|
|
FROM debian:trixie-slim
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
build-essential \
|
|
python3 \
|
|
python3-pip \
|
|
netcat-openbsd \
|
|
jq \
|
|
iproute2 \
|
|
net-tools \
|
|
wireguard-tools \
|
|
git \
|
|
iptables \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Go and build wireguard-go, then clean up
|
|
ARG TARGETARCH
|
|
RUN curl -fsSL "https://go.dev/dl/go1.23.6.linux-${TARGETARCH}.tar.gz" \
|
|
| tar -C /usr/local -xz && \
|
|
export PATH="/usr/local/go/bin:$PATH" && \
|
|
git clone https://git.zx2c4.com/wireguard-go && \
|
|
cd wireguard-go && \
|
|
make && \
|
|
cp wireguard-go /usr/local/bin/ && \
|
|
cd .. && \
|
|
rm -rf wireguard-go /usr/local/go && \
|
|
apt-get purge -y --auto-remove build-essential curl
|
|
|
|
RUN pip3 install --break-system-packages base58
|
|
|
|
# Copy only the compiled binaries from the builder stage
|
|
COPY --from=builder /usr/src/nym/target/release/nym-node /usr/local/bin/
|
|
COPY --from=builder /usr/src/nym/target/release/nym-network-requester /usr/local/bin/
|
|
COPY --from=builder /usr/src/nym/target/release/nym-socks5-client /usr/local/bin/
|
|
|
|
COPY ./docker/localnet/build_topology.py /usr/local/bin/
|
|
|
|
WORKDIR /nym
|
|
|
|
CMD ["nym-node", "--help"]
|