Public Repository

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Dockerfile links

Usage instructions

Here are a few tips on using this image to go from 0 to 60 in no time.

Django instructions

The following shell commands will generate an example Django project (a Python web framework),
if you just want to get started quickly.

pip install django==1.7.11
django-admin startproject {{ my_project }}
cd {{ my_project }}
django-admin startapp common

This requires quite a bit of custom code. If you would rather experiment,
then follow the Mezzanine instructions instead.

Mezzanine instructions

The following shell commands will generate an example Mezzanine project (a Django blog framework),
if you want to get started with a blog website, for example.

pip install mezzanine==4.0.1
mezzanine-project {{ my_project }}

Git instructions

If you are starting a new project, then it should be associated with a git repo for the following Python instructions to work. If you already have a git repo, and have a pip installable project, then you can skip this section.

git init
git tag 1.0.0

Python instructions

Make sure you have a setup.cfg file like so.

name = {{ my_project }}

Make sure you have a file like so.

from setuptools import setup

    setup_requires=['pbr>=1.9', 'setuptools>=17.1'],

Make sure you have a requirements.txt file like so.


and you will need to edit the {{ my_project }}/ file like so.

cat >> {{ my_project }}/{{ my_project }}/ <<EOF

Apache HTTPD instructions

To use Apache HTTPD effectively, it must be configured, so write a file at the root of your project with the following configuration.

ServerName localhost
WSGIPythonPath /usr/local/src/{{ my_project }}

<VirtualHost *:80>
    #ServerName {{ my_project }}.{{ my_domain }}
    WSGIPassAuthorization On
    WSGIScriptAlias / /usr/local/src/{{ my_project }}/{{ my_project }}/
    Alias /static/ /usr/local/src/{{ my_project }}/static/
    <Directory /usr/local/src/{{ my_project }}/static>
        Require all granted
    <Directory /usr/local/src/{{ my_project }}/media>
        Require all granted
    <Directory /usr/local/src/{{ my_project }}/{{ my_project }}>
            Require all granted

Docker instructions

Once you have a Django project started, or if want to Dockerize an existing Django project,
then all you need to do is write a Dockerfile similar to the following.

FROM andydude64/python-django-httpd-openjdk:2.7.12-1.7.11-2.4.23-8-jre

ENV APACHE_VHOST=000-default.conf \
    DJANGO_SRCDIR=/usr/local/src \
    DJANGO_SETTINGS_MODULE={{ my_project }}.settings \
    DJANGO_ADMIN_EMAIL=root@localhost \

# Configure Apache HTTPD
COPY {{ my_project }}.apache2.conf \
RUN rm -f /etc/apache2/sites-enabled/$APACHE_VHOST \
    && ln -s ../sites-available/$APACHE_VHOST \

# Configure Django and static files
COPY . $DJANGO_SRCDIR/{{ my_project }}
RUN pip install --upgrade pip \
    && pip install -e $DJANGO_SRCDIR/{{ my_project }} \
    && python $DJANGO_SRCDIR/{{ my_project }}/ \
        collectstatic --noinput \
    && python $DJANGO_SRCDIR/{{ my_project }}/ migrate \
    && python $DJANGO_SRCDIR/{{ my_project }}/ \
        createsuperuser --noinput \
        --email=$DJANGO_ADMIN_EMAIL \
        --username=$DJANGO_ADMIN_USERNAME \
    && python -c "\
import django; django.setup(); \
from django.contrib.auth.models import User; \
u = User.objects.get(username='$DJANGO_ADMIN_USERNAME'); \
u.set_password('$DJANGO_ADMIN_PASSWORD');" \
    && chown -R www-data:www-data $DJANGO_SRCDIR/{{ my_project }}

CMD [""]

After you have added such a Dockerfile to the root of your project, then you can run the
following shell commands to create and start a new container with your project.

docker build --tag {{ my_hub_repo }}/{{ my_project }}:latest .
docker run -Pit {{ my_hub_repo }}/{{ my_project }}

Makefile instructions

If you would like, it helps to write a Makefile with common Docker commands.

.PSEUDO: all
all: build

.PSEUDO: build
    docker build --tag {{ my_hub_repo }}/{{ my_project }}:latest .

.PSEUDO: run
    docker run -Pit {{ my_hub_repo }}/{{ my_project }}
Docker Pull Command