ISSUE-238 Improved build steps in Dockerfile to allow caching and improved docker instructions

pull/239/head
Fabio Kruger 5 years ago
parent 33d0e07537
commit 810bb5ea36

@ -1,4 +1,6 @@
.git/
.vscode/
screenshot/
tests/
*.txt
!/requirements.txt

@ -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"]

@ -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`:
```

Loading…
Cancel
Save