scragg0x / realms-wiki

Git based wiki inspired by Gollum
http://realms.io
GNU General Public License v2.0
831 stars 90 forks source link

[Docker]: Optimized Dockerfile #102

Open prologic opened 8 years ago

prologic commented 8 years ago

The current Docker image is huge!:

$ docker images realms/realms-wiki
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
realms/realms-wiki   latest              08a03836b580        2 weeks ago         963.4 MB

We should optimize this :)

scragg0x commented 8 years ago

Hmm not sure why it's so big.

prologic commented 8 years ago

Me neither but I love the alpine base image as a base.

My understanding is that realms-wiki is mostly Python so I expect to have a base image that just runs realms-wiki (couchdb should be a separate container) to be around the ~30-40MB mark.

I've been switching to leaner/meaner image sizes for a lot of my Dockerized apps that I've been seeing HUGE improvements in image sizes, pull times and even startup times!

See: https://hub.docker.com/r/prologic/

James Mills / prologic

E: prologic@shortcircuit.net.au W: prologic.shortcircuit.net.au

On Tue, Dec 29, 2015 at 5:40 PM, Matthew Scragg notifications@github.com wrote:

Hmm not sure why it's so big.

— Reply to this email directly or view it on GitHub https://github.com/scragg0x/realms-wiki/issues/102#issuecomment-167915310 .

prologic commented 8 years ago

I'm afraid I suck :)

This is as far as I've gotten for the time being:

FROM prologic/python-runtime:2.7

EXPOSE 80

ENTRYPOINT ["realms-wiki"]
CMD []

RUN apk -U add build-base
RUN apk -U add python-dev
RUN apk -U add libffi-dev
RUN apk -U add openldap-dev

ENV PYTHONHOME=/usr

RUN pip install realms-wiki

I keep running into this build error installing python-ldap:

    writing byte-compilation script '/tmp/tmp3cjd7c.py'
    /usr/bin/python -O /tmp/tmp3cjd7c.py
    ImportError: No module named site
    error: command '/usr/bin/python' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-gJ2buz/python-ldap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-K1KbjC-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-gJ2buz/python-ldap
The command '/bin/sh -c pip install realms-wiki' returned a non-zero code: 1

For the life of me I can't remember how to fix this! (I've tried setting PYTHONHOME)