diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9c743ec --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +data/ +.github/ +tests/ +docs/ +db/ +*.md +*.txt +*.sh +test.py +.flake8 +.gitattributes +.gitignore +.git/ diff --git a/Dockerfile b/Dockerfile index 11ef2bf..84cdf66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"]