Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Docker from local code rather than git #77

Closed
OllieJC opened this issue Jul 17, 2020 · 4 comments
Closed

Suggestion: Docker from local code rather than git #77

OllieJC opened this issue Jul 17, 2020 · 4 comments

Comments

@OllieJC
Copy link
Contributor

OllieJC commented Jul 17, 2020

After raising #75 and trying to develop a new parser I realised that the code pulls from GitHub rather than building from local files.

A suggestion would be to use the local files rather than git, for example (as well as use a python base image):

FROM python:3-alpine
COPY requirements.txt /unfurl/requirements.txt

RUN cd /unfurl && \
    pip3 install -r requirements.txt

COPY . /unfurl
RUN sed -i 's/^host.*/host = 0.0.0.0/' /unfurl/unfurl.ini

WORKDIR /unfurl
ENTRYPOINT ["python3", "unfurl_app.py"]

The reason for the two COPYs is so that between changes, builds are cached up to the second COPY and then those changes built rather than all the dependencies every time.

I figured I'd raise an issue rather than another PR to get some comments. It would be good to get @weslambert thoughts.

@weslambert
Copy link
Contributor

Hi @OllieJC, and thanks for the suggestions.

I think the original way I had the Dockerfile and associated files were geared more towards my use case, so they may not have been optimized for quick testing, so thanks for the contributions there.

I don't think there would be any issue with the additional copies, but I'd be curious how much that adds size-wise via the additional layers, if at all.

Have you compared the size of the python:3-alpine-based image and alpine:3.10? I would think the Python image would be much larger, but I haven't tested it.

@obsidianforensics
Copy link
Owner

Thanks to both of you for your thoughts on this. I've used Docker very little, so I'll defer to whatever you think is best and be happy to merge it.

@OllieJC
Copy link
Contributor Author

OllieJC commented Jul 17, 2020

Good point @weslambert about sizes! You're right with your thinking, the overall image size once built is ~42Mb larger.
In that case, something like this? This also forgoes the .git folder and docs folder for a little space saving.

FROM alpine:3.10

COPY requirements.txt /unfurl/requirements.txt

RUN apk update && apk add --no-cache git python3 && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
    if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
    pip3 install -r /unfurl/requirements.txt

COPY unfurl/ /unfurl/unfurl/
COPY *.py unfurl.ini /unfurl/
RUN sed -i 's/^host.*/host = 0.0.0.0/' /unfurl/unfurl.ini

WORKDIR /unfurl
ENTRYPOINT ["/usr/bin/python3", "unfurl_app.py"]

@weslambert
Copy link
Contributor

Looks good to me! 👍 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants