From 810bb5ea361c616344869fcdad22001c9fdde795 Mon Sep 17 00:00:00 2001 From: Fabio Kruger Date: Sat, 13 Jul 2019 22:18:18 +0200 Subject: [PATCH] ISSUE-238 Improved build steps in Dockerfile to allow caching and improved docker instructions --- .dockerignore | 2 ++ Dockerfile | 23 +++++++++++++++-------- README.md | 15 ++++++++++++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3214bce..81b77d2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,6 @@ .git/ .vscode/ +screenshot/ +tests/ *.txt !/requirements.txt \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 16490c3..1592466 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,27 @@ FROM python:3.7-alpine as build -RUN apk add --no-cache linux-headers g++ gcc libxml2-dev libxml2 libxslt-dev -COPY requirements.txt /opt/sherlock/ WORKDIR /wheels +RUN apk update --no-cache \ + && apk add --no-cache \ + g++ \ + gcc \ + libxml2 \ + libxml2-dev \ + libxslt-dev \ + linux-headers +COPY requirements.txt /opt/sherlock/ RUN pip3 wheel -r /opt/sherlock/requirements.txt + FROM python:3.7-alpine -COPY --from=build /wheels /wheels -COPY . /opt/sherlock/ WORKDIR /opt/sherlock -RUN pip3 install -r requirements.txt -f /wheels \ - && rm -rf /wheels \ - && rm -rf /root/.cache/pip/* - ARG VCS_REF ARG VCS_URL="https://github.com/sherlock-project/sherlock" LABEL org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url=$VCS_URL +COPY --from=build /wheels /wheels +COPY . /opt/sherlock/ +RUN pip3 install -r requirements.txt -f /wheels \ + && rm -rf /wheels \ + && rm -rf /root/.cache/pip/* ENTRYPOINT ["python", "sherlock.py"] diff --git a/README.md b/README.md index abe056d..60fa3bf 100644 --- a/README.md +++ b/README.md @@ -103,13 +103,22 @@ docker build -t mysherlock-image . Once the image is built sherlock can be invoked by running the following: ``` -docker run --rm mysherlock-image user123 +docker run --rm -t mysherlock-image user123 ``` -The optional ```--rm``` flag removes the container filesystem on completion to prevent cruft build-up. See https://docs.docker.com/engine/reference/run/#clean-up---rm +The optional ```--rm``` flag removes the container filesystem on completion to prevent cruft build-up. See https://docs.docker.com/engine/reference/run/#clean-up---rm -One caveat is the text file that is created will only exist in the container so you will not be able to get at that. +The optional ```-t``` flag allocates a pseudo-TTY which allows colored output. See https://docs.docker.com/engine/reference/run/#foreground +It is possible to use the following command to access the saved results: + +``` +docker run --rm -t -v "$PWD/results:/opt/sherlock/results" mysherlock-image -o /opt/sherlock/results/text.txt user123 +``` + +The ```-v "$PWD/results:/opt/sherlock/results"``` option tells docker create (or use) the folder `results` in the +present working directory and to mount it at `/opt/sherlock/results` on the docker container. +The `-o /opt/sherlock/results/text.txt` option tells `sherlock` to output the result Or you can simply use "Docker Hub" to run `sherlock`: ```