Public Repository

Last pushed: 5 months ago
Short Description
Python image based on debian:wheezy and with usefull scripts.
Full Description

Docker IMAGE for Python 3.4.1

Contains:

  • Python 3.4.1
  • Virtualenv

Image works with this tree stucture in /srv directory. There should be all of your data.

  • /srv/ - mount your app here
  • /srv/app/ - this is place for your python code
  • /srv/venv/ - python 3.4.1 virtualenv
  • /srv/logs/ - almost all important logs are here

After start the container, start script call:

pip install -r /srv/app/requirements.txt

It installs requirements of your app. After this step, script will call /src/app/init.sh. There should be everything what you want to do after container starts. For example:

#!/bin/bash

source ~/venv/bin/activate
cd /srv/app
python manage.py migrate
python manage.py collectstatic --noinput

At the end, gunicorn is fired:

/srv/venv/bin/gunicorn -u app -g app -b 0.0.0.0:8000 -w $WORKERS --error-logfile /srv/logs/error.log --access-logfile /srv/logs/access.log --reload app

As you can see, gunicorn looks for app.py file in /srv/app. It's standard wsgi application. Here is example for django:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "triatlon.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

If you are happy with this behaviour, you can run your app:

docker run -d --name=pyapp -p 10001:80 -v /my/site:/srv rosti/python:3.4.1
Docker Pull Command
Owner
rosti

Comments (0)