Skip to content

Commit 2bd75d9

Browse files
authored
Image size improvements and pinned Netexec version
Minimized final image size (From ~2 GB to ~350 MB) Pinned a stable NetExec version Signed-off-by: Professor Bossetti <emanuelebosimini@gmail.com>
1 parent aec6448 commit 2bd75d9

1 file changed

Lines changed: 38 additions & 12 deletions

File tree

Dockerfile

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
1-
FROM python:3.11-slim
2-
1+
# --- Build Stage ---
2+
FROM python:3.13-slim-bookworm AS builder
3+
ENV TAG=1.4.0
34
ENV LANG=C.UTF-8
45
ENV LC_ALL=C.UTF-8
56
ENV PIP_NO_CACHE_DIR=off
67

78
WORKDIR /usr/src/netexec
89

10+
# Install build dependencies
911
RUN apt-get update && \
10-
apt-get install -y libffi-dev libxml2-dev libxslt-dev libssl-dev openssl autoconf g++ python3-dev curl git
11-
RUN apt-get update
12-
# Get Rust
13-
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
14-
# Add .cargo/bin to PATH
12+
apt-get install -y --no-install-recommends \
13+
libffi-dev \
14+
libxml2-dev \
15+
libxslt-dev \
16+
libssl-dev \
17+
openssl \
18+
autoconf \
19+
g++ \
20+
python3-dev \
21+
curl \
22+
git \
23+
unzip \
24+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
25+
26+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain stable
1527
ENV PATH="/root/.cargo/bin:${PATH}"
16-
# Check cargo is visible
17-
RUN cargo --help
1828

19-
COPY . .
20-
RUN pip install .
29+
RUN git clone --depth 1 --branch v${TAG} https://github.com/Pennyw0rth/NetExec.git . \
30+
&& pip install .
31+
32+
FROM python:3.13-slim-bookworm
33+
34+
ENV LANG=C.UTF-8
35+
ENV LC_ALL=C.UTF-8
36+
ENV PIP_NO_CACHE_DIR=off
37+
38+
WORKDIR /usr/src/netexec
39+
40+
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
41+
COPY --from=builder /usr/local/bin /usr/local/bin
42+
43+
RUN apt-get update && \
44+
apt-get install -y --no-install-recommends \
45+
openssl \
46+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
2147

22-
ENTRYPOINT [ "nxc" ]
48+
ENTRYPOINT ["nxc"]

0 commit comments

Comments
 (0)