Skip to content
This repository has been archived by the owner on Aug 5, 2019. It is now read-only.

Commit

Permalink
Slim down the Docker build
Browse files Browse the repository at this point in the history
This rearranges the Dockerfile to get a slimmer final image.
  • Loading branch information
Ira W. Snyder committed Aug 14, 2015
1 parent 4ce3c4e commit 4b587f0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 184 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
lcogt_mezzanine/static/media/files/*
.dockerignore
.git
lcogt_mezzanine/static/media/files/*
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ local_settings.py
lcogt_mezzanine/static/media/files/*
/src
/src/*


*.log
67 changes: 16 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,46 @@
# it avoids duplicating all of the Python code and static files in two containers.
# It is convenient to have the whole webapp logically grouped into the same container.
#
# You can choose to expose the nginx and uwsgi ports separately, or you can
# just default to using the nginx port only (recommended). There is no
# requirement to map all exposed container ports onto host ports.
#
# Build with
# docker build -t docker.lcogt.net/mezzanine:latest .
#
# Push to Registry with
# docker push docker.lcogt.net/mezzanine:latest
#
# To run with nginx + uwsgi both exposed:
# docker run -d -p 8100:80 -m="2048m" --restart=always -v /net/mfs/data4/webfiles:/var/www/apps/lcogt_mezzanine/static/media/files --name=website docker.lcogt.net/mezzanine:latest
#
# See the notes in the code below about NFS mounts.
#
################################################################################

FROM centos:centos7
MAINTAINER LCOGT <[email protected]>

# nginx (http protocol) runs on port 80
EXPOSE 80
ENTRYPOINT [ "/init" ]

# Setup the Python Django environment
ENV PYTHONPATH /var/www/apps
ENV DJANGO_SETTINGS_MODULE lcogt_mezzanine.settings

# Install packages and update base system
RUN yum -y install epel-release \
&& yum -y install cronie libjpeg-devel nginx python-pip mysql-devel python-devel supervisor \
&& yum -y groupinstall "Development Tools" \
&& yum -y update
&& yum -y update \
&& yum -y clean all

# Install the LCOGT Mezzanine webapp Python required packages
COPY lcogt_mezzanine/pip-requirements.txt /var/www/apps/lcogt_mezzanine/
RUN pip install pip==1.3 \
&& pip install -r /var/www/apps/lcogt_mezzanine/pip-requirements.txt

# Ensure crond will run on all host operating systems
RUN sed -i -e 's/\(session\s*required\s*pam_loginuid.so\)/#\1/' /etc/pam.d/crond

# Setup the Python Django environment
ENV PYTHONPATH /var/www/apps
ENV DJANGO_SETTINGS_MODULE lcogt_mezzanine.settings
ENV BRANCH ${BRANCH}
#ENV BUILDDATE ${BUILDDATE}

# Copy configuration files
COPY config/init /init
COPY config/uwsgi.ini /etc/uwsgi.ini
COPY config/nginx/* /etc/nginx/
COPY config/processes.ini /etc/supervisord.d/processes.ini
COPY config/crontab.root /var/spool/cron/root

# nginx (http protocol) runs on port 80
# uwsgi (uwsgi protocol) runs on port 9090
EXPOSE 80 9090

# Entry point is the supervisord daemon
ENTRYPOINT [ "/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf" ]

# Copy the LCOGT Mezzanine webapp files
COPY lcogt_mezzanine /var/www/apps/lcogt_mezzanine

# Install the LCOGT Mezzanine webapp Python required packages
RUN pip install pip==1.3 \
&& pip install -r /var/www/apps/lcogt_mezzanine/pip-requirements.txt

# It is not possible to access NFS mount points during the docker build
# process. If the chmod cannot be run externally, and must be run every
# time this docker image is started, supervisord can handle it with some
# additional configuration.
#
# Likewise, if the "python manage.py collectstatic" process needs to be
# run every time this node is restarted, supervisord can handle it with
# some additional configuration.
#
# In order to access the NFS mount while this docker image is running,
# you must start the instance with the argument:
#
# -d /path/to/nfs/mount/on/docker/host:/var/www/apps/lcogt_mezzanine/files
#
# These commands are left here for reference:
# RUN chmod 777 /var/www/apps/lcogt_mezzanine/static/media/files/
# RUN mount_nfs -o resvport mfs.lco.gtn:/data4/webfiles /var/www/apps/lcogt_mezzanine/static/media/files

# Setup the LCOGT Mezzanine webapp
RUN python /var/www/apps/lcogt_mezzanine/manage.py collectstatic --noinput

# Upload the latest version of the data for the django_lcogtbiblio (Bibliometrics) app
# RUN python /var/www/apps/lcogt_mezzanine/manage.py loaddata /var/www/apps/lcogt_mezzanine/fixtures/biblio_snapshot.json
44 changes: 0 additions & 44 deletions Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions config/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

TOPDIR="/var/www/apps/lcogt_mezzanine"

# Django static files
python $TOPDIR/manage.py collectstatic --noinput

# Upload the latest version of the data for the django_lcogtbiblio (Bibliometrics) app
#python $TOPDIR/manage.py loaddata $TOPDIR/fixtures/biblio_snapshot.json

# Run under supervisord
exec /usr/bin/supervisord -n -c /etc/supervisord.conf
86 changes: 0 additions & 86 deletions docker/lcogt_mezzanine.dockerfile

This file was deleted.

0 comments on commit 4b587f0

Please sign in to comment.