Changed docker base image to python3.9-alpine

This commit is contained in:
Caleb Stewart 2021-08-31 17:32:15 -04:00
parent 7273e6ad43
commit a09cab24f3
2 changed files with 32 additions and 25 deletions

13
.dockerignore Normal file
View File

@ -0,0 +1,13 @@
data/
.github/
tests/
docs/
db/
*.md
*.txt
*.sh
test.py
.flake8
.gitattributes
.gitignore
.git/

View File

@ -1,4 +1,4 @@
FROM alpine:3.13.5 as builder
FROM python:3.9-alpine as builder
# Install python3 and development files
RUN set -eux \
@ -7,44 +7,38 @@ RUN set -eux \
libffi-dev \
linux-headers \
openssl-dev \
python3 \
python3-dev \
musl-dev \
cargo
cargo \
libstdc++
# Copy pwncat source
COPY . /pwncat
COPY . /opt/pwncat
# Setup virtual environment
RUN set -eux \
&& python3 -m venv /opt/pwncat \
&& /opt/pwncat/bin/python -m ensurepip \
&& /opt/pwncat/bin/python -m pip install -U pip setuptools wheel setuptools_rust
&& python -m pip install -U pip setuptools wheel setuptools_rust
# Setup pwncat
RUN set -eux \
&& cd /pwncat \
&& /opt/pwncat/bin/python setup.py install
&& cd /opt/pwncat \
&& python setup.py install
# Cleanup
FROM python:3.9-alpine as final
# Add libstdc++ and create the working directory
RUN set -eux \
&& find /opt/pwncat/lib -type f -name '*.pyc' -print0 | xargs -0 -n1 rm -rf || true \
&& find /opt/pwncat/lib -type d -name '__pycache__' -print0 | xargs -0 -n1 rm -rf || true
FROM alpine:3.13.5 as final
RUN set -eux \
&& apk add --no-cache \
python3 libstdc++ \
&& find /usr/lib -type f -name '*.pyc' -print0 | xargs -0 -n1 rm -rf || true \
&& find /usr/lib -type d -name '__pycache__' -print0 | xargs -0 -n1 rm -rf || true \
&& apk add --no-cache libstdc++ \
&& mkdir /work
COPY --from=builder /opt/pwncat /opt/pwncat
# Copy installed packages from builder image
COPY --from=builder /usr/local/lib/python3.9 /usr/local/lib/python3.9
COPY --from=builder /usr/local/bin/pwncat /usr/local/bin/pwncat
RUN /opt/pwncat/bin/python -m pwncat --download-plugins
# Ensure we have the pwncat plugins downloaded
RUN python -m pwncat --download-plugins
# Set working directory
WORKDIR /work
ENTRYPOINT ["/opt/pwncat/bin/pwncat"]
# Entrypoint is pwncat itself
ENTRYPOINT ["python", "-m", "pwncat"]