forked from atbaker/docker-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,26 @@ | |
|
||
FROM ubuntu:precise | ||
|
||
MAINTAINER Andrew T. Baker <[email protected]> | ||
# Add yourself as maintainer | ||
MAINTAINER | ||
|
||
# Add the Django app to the container and install its requirements | ||
ADD sd_sample_project /var/www/django | ||
# The ENV command applies environment variables to the rest of the build steps. | ||
# Add these environment variables to the build: | ||
# PYTHONPATH=$PYTHONPATH:/var/www/django/sd_sample_project | ||
# DJANGO_SETTINGS_MODULE=sd_sample_project.settings.production | ||
# SECRET_KEY no-so-secret # Fix for your own site! | ||
|
||
# Add a command to copy the sd_sample_project to the /var/www/django directory | ||
# in the image | ||
# (your command here) | ||
|
||
# Install pip and requirements | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python-pip | ||
RUN pip install virtualenv | ||
RUN virtualenv /var/www/venv | ||
RUN /var/www/venv/bin/pip install -r /var/www/django/requirements/production.txt | ||
|
||
# Syncdb (a sqlite3 database for simplicity) | ||
ENV PYTHONPATH $PYTHONPATH:/var/www/django/sd_sample_project | ||
ENV DJANGO_SETTINGS_MODULE sd_sample_project.settings.production | ||
ENV SECRET_KEY no-so-secret # Fix for your own site! | ||
RUN /var/www/venv/bin/django-admin.py syncdb --migrate --noinput | ||
RUN /var/www/venv/bin/django-admin.py collectstatic --noinput | ||
|
||
|
@@ -24,12 +31,16 @@ RUN mkdir /var/log/gunicorn | |
RUN touch /var/log/gunicorn/access.log | ||
RUN touch /var/log/gunicorn/error.log | ||
|
||
# Add project to PYTHONPATH | ||
RUN echo PYTHONPATH=$PYTHONPATH:/var/www/django/sd_sample_project >> /root/.bashrc | ||
|
||
# Clean up APT when done | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
EXPOSE 80 | ||
# Add a command to expose port 80 to the host container | ||
# (your command here) | ||
|
||
# Add a CMD statement to start the gunicorn server. The basic command is: | ||
# /var/www/venv/bin/gunicorn sd_sample_project.wsgi:application | ||
# (your command here) | ||
|
||
CMD /var/www/venv/bin/gunicorn sd_sample_project.wsgi:application --bind 0.0.0.0:80 | ||
# HINT: You also need to use the --bind option to tell gunicorn to respond to | ||
# requests from all hosts, since all incoming requests through docker will | ||
# appear to be from another machine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters