Files
docker-django-test/README.rst
heinzel cd193da78f FIX #1
2019-10-18 16:50:21 +02:00

100 lines
3.0 KiB
ReStructuredText

ABOUT
=====
Docker container for django-test.
AUTHOR
======
Jens Kleineheismann <heinzel@heinzelwelt.de>
DESCRIPTION
===========
This docker image is derivated from the official Fedora image
(https://hub.docker.com/_/fedora).
It will contain and run
- apache httpd
- mod_ssl
- certbot
- python3 mod_wsgi
- django-test django project
BUILD
=====
- ``make``
- ``make test``
or alternatively the *long* way:
- ``git clone https://dev.heinzelwerk.de/git/python/django-test src/django-test``
- ``docker build -t django-test .``
- ``dgoss run django-test``
USAGE
=====
- ``docker run -ti --rm -v $(pwd)/conf:/srv/etc:Z -e DJANGO_SYNCDB=true django-test django-createsuperuser``
- ``docker run -ti --rm -v $(pwd)/conf:/srv/etc:Z -v $(pwd)/conf/letsencrypt:/etc/letsencrypt:Z -p 80:80 django-test certbot``
- ``docker run -d --name django-test -v $(pwd)/conf:/srv/etc:Z -p 80:80 -p 443:443 django-test``
Django settings
---------------
The django project will read its settings from ``/srv/etc/django/settings.py``
Note: this file will be read only upon container startup.
If this settings file does not exist, the default settings will be installed
there.
To provide your own settings file, you can mount a directory into the
container with the -v option of the ``docker run`` command.
SELinux
-------
If your system is enforcing SELinux policies you have to set the correct
file contexts to mounted files and directories.
On recent docker versions, this can be done with the Z parameter of the
-v option (-v host_path:container_path:Z).
HTTP Port
---------
The httpd process is listening on port 80/tcp.
Thus you probably want to publish this port with the -p option.
HTTPS Port / TLS / X.509 Certificates / certbot
-----------------------------------------------
To enable HTTPS on port 443/tcp you can either provide a key and
certificate chain as pem files, or you can use certbot to obtain a
*Let's Encrypt* certificate.
If you already have valid certificates for the domain, you can mount
the key as ``/srv/etc/certs/privkey.pem`` and the certificate
chain as ``/srv/etc/certs/fullchain.pem``.
For using certbot you have to mount a directory to ``/etc/letsencrypt``.
Then run the container once in interactive mode with the ``certbot`` command
argument to obtain a certificate from *Let's Encrypt*. The certificate will
be stored in the mounted directory.
If necessary the certificate will be renewed upon container startup.
Environment variables
---------------------
The following **environment variables** are supported and
can be set with the -e option of the ``docker run`` command:
- LOG_LEVEL (default: error)
-- to set the httpd LogLevel directive
- ENABLE_STATUS_ENDPOINTS (default: false)
-- if true, then the httpd status-handler is mapped to /.status
and the httpd info-handler is mapped to /.info
- DJANGO_SYNCDB (default: false)
-- if true, then apply django database migrations upon startup
LICENCE
=======
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted.