From e0e1cdc8fa7badf5fa3e0bfd2dc66e762ef0d36d Mon Sep 17 00:00:00 2001 From: Alireza Mosajjal Date: Sat, 11 Feb 2017 01:04:51 +0330 Subject: [PATCH] Changed mitmproxy dockerfile to the one privded by them (#233) --- mitmproxy/Dockerfile | 76 ++++++++++++++++++++-------------- mitmproxy/docker-entrypoint.sh | 13 ++++++ mitmproxy/requirements.txt | 1 + 3 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 mitmproxy/docker-entrypoint.sh create mode 100644 mitmproxy/requirements.txt diff --git a/mitmproxy/Dockerfile b/mitmproxy/Dockerfile index a87489d..b6bb4b5 100644 --- a/mitmproxy/Dockerfile +++ b/mitmproxy/Dockerfile @@ -1,38 +1,50 @@ -FROM debian:stretch +FROM alpine:3.4 MAINTAINER Jessie Frazelle +ENV LANG=en_US.UTF-8 -RUN apt-get update && apt-get install -y \ - libxslt1.1 \ - libjpeg62-turbo \ - python-minimal \ - python-pip \ - --no-install-recommends \ - && rm -rf /var/lib/apt/lists/* +COPY requirements.txt /tmp/requirements.txt -ENV LANG en_US.UTF-8 -EXPOSE 8080 +# add our user first to make sure the ID get assigned consistently, +# regardless of whatever dependencies get added +RUN addgroup -S mitmproxy && adduser -S -G mitmproxy mitmproxy \ + && apk add --no-cache \ + su-exec \ + git \ + g++ \ + libffi \ + libffi-dev \ + libjpeg-turbo \ + libjpeg-turbo-dev \ + libstdc++ \ + libxml2 \ + libxml2-dev \ + libxslt \ + libxslt-dev \ + openssl \ + openssl-dev \ + python3 \ + python3-dev \ + zlib \ + zlib-dev \ + && python3 -m ensurepip \ + && LDFLAGS=-L/lib pip3 install -r /tmp/requirements.txt \ + && apk del --purge \ + git \ + g++ \ + libffi-dev \ + libjpeg-turbo-dev \ + libxml2-dev \ + libxslt-dev \ + openssl-dev \ + python3-dev \ + zlib-dev \ + && rm /tmp/requirements.txt \ + && rm -rf ~/.cache/pip -RUN buildDeps=' \ - gcc \ - libjpeg-dev \ - libffi-dev \ - libssl-dev \ - libxml2-dev \ - libxslt1-dev \ - python-dev \ - python-setuptools \ - zlib1g-dev \ - ' \ - && set -x \ - && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ - && pip install setuptools mitmproxy \ - && apt-get purge -y --auto-remove ${buildDeps} \ - && rm -rf /var/lib/apt/lists/* +VOLUME /home/mitmproxy/.mitmproxy -ENV HOME /home/mitm -RUN useradd --create-home --home-dir $HOME mitm \ - && chown -R mitm:mitm $HOME +COPY docker-entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["docker-entrypoint.sh"] -USER mitm - -ENTRYPOINT [ "mitmproxy" ] +EXPOSE 8080 8081 +CMD ["mitmproxy"] diff --git a/mitmproxy/docker-entrypoint.sh b/mitmproxy/docker-entrypoint.sh new file mode 100644 index 0000000..a4abe4c --- /dev/null +++ b/mitmproxy/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +MITMPROXY_PATH="/home/mitmproxy/.mitmproxy" + +if [[ "$1" = "mitmdump" || "$1" = "mitmproxy" || "$1" = "mitmweb" ]]; then + mkdir -p "$MITMPROXY_PATH" + chown -R mitmproxy:mitmproxy "$MITMPROXY_PATH" + + su-exec mitmproxy "$@" +else + exec "$@" +fi diff --git a/mitmproxy/requirements.txt b/mitmproxy/requirements.txt new file mode 100644 index 0000000..59bcb3f --- /dev/null +++ b/mitmproxy/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/mitmproxy/mitmproxy.git@master