Simple Docker Image to create a DjangoCMS instance with a PostgreSQL data base
587
django CMS is a free and open source content management system platform for publishing content on the World Wide Web and intranets. It is written in Django language framework, with Python.
(Source: Wikipedia)
It provides a productive django CMS environment in a Docker container.
It's based on the official python image and utilizes the django CMS Installer.
The resulting web site can be served with django's internal development server, but there's also a builtin option to use gunicorn instead, which is more secure and stable and therefore useful for productive sites.
A PostgreSQL database is required in order to run this image. However, this requirement can easily be met using a PostgreSQL Docker image. The Docker Compose samples provided in this repository use this method.
3.9.0, 3.9, 3, latest - django CMS 3.9.0In order to run this image, you need a working installation of Docker.
Furthermore Docker Compose is recommended. Although it is possible to provide all arguments in Docker's command line interface, all documentation in this repository assumes that Docker Compose is installed.
docker-compose.ymlenv/djangocms.env with parameters from djangocms.envenv/postgres.env with parameters from postgres.envsecrets/ and put the following files inside this folderpostgres_db.txt containing a string with the name of your PostgreSQL database (not to be mixed up with the host name)postgres_user.txt containing the username to access your PostgreSQL databasepostgres_password.txt containing the user password for the user to access your PostgreSQL databasedocker-compose up -dWhen the Docker container is started, it first checks if the file /app/bin/activate is present. If it's not present the system assumes that the system needs to be configured and will setup a venv in the /app/ folder. Furthermore it will install several requirements to run django CMS.
After that the startup script checks if the folder /app/projects/ is present. If it's presemt already, the system assumes that this is either not the first boot of the system or that you try to migrate from another installation and will skip the setup process. Otherwise a new django CMS project will be initialized in /app/projects/<project_name>/ (where <project_name> is an environment variable - see below).
Sometimes you might want to migrate an existing project to a new docker container, e.g. when upgrading to a newer version. To perform a migration of an existing project (stored in /your/host/path/projects/<project_name>) make sure that the Docker container recognizes the folder /your/host/path/projects as /app/projects. A good way to achieve this to mount the host folder /your/host/path to /app in the container. Your docker-compose.yml should look like this
app:
[...]
volumes:
- /your/host/path:/app
[...]
In principle you can modify the system to your needs by logging into the container and performing the changes you desire. However, this procedure is not optimal as these changes won't sustain typical procedures (like upgrading the Docker image). As the more likely changes are limited to enhance the container's features with additional Linux and/or Python packages, the image provides ways to permanently add those.
This image is based on Debian Stable. In order to add a Debian package, modify /app/req/user_debianpackages.txt and add one package per line. The package shall be installed when restarting the Docker container.
In order to add a Python package, modify /app/req/pythonpackages.txt and add one package per line. The package shall be installed (using pip) when restarting the Docker container.
Environment variables are stored in the env folder and split up into postgres.env (covering database options) and djangocms.env (covering everything else). With a little knowledge in Docker compose, you could also specify those parameters directly in the Docker compose file. Personally, I prefer to keep those parameters in seperate files.
project_name (default=djangocms)
See project_name in the django CMS Installer Argument reference
init_i18 (default=yes)
See i18 in the django CMS Installer Argument reference
init_use_tz (default=yes)
See use_tz in the django CMS Installer Argument reference
init_timezone (no default)
See timezone in the django CMS Installer Argument reference
init_permissions (default=yes)
See permissions in the django CMS Installer Argument reference
init_languages (space seperated, no default)
See languages in the django CMS Installer Argument reference, take care to specify a space seperated list as opposed to a comma seperated list in django CMS Installer calls
init_bootstrap (default=no)
See bootstrap in the django CMS Installer Argument reference
init_starting-page (default=no)
See starting-page in the django CMS Installer Argument reference
use_gunicorn (yes|no, default=yes)
Choose no to use the internal development server or yes to use gunicorn instead. Gunicorn is safer and recommended to be used on productive pages, however the internal server is much more convenient for development.
Different to other parameters, this parameter can be changed whenever you restart the docker container
gunicorn_number_of_workers (number, default=2)
See https://docs.gunicorn.org/en/stable/run.html#commonly-used-arguments --workers
Different to other parameters, this parameter can be changed whenever you restart the docker container
internal_port (number, default=8000)
The port inside of the docker container the (gunicorn or development) server listens. Actually I can see no practical reason to change this. However, if you do, make sure to keep it aligned with your docker-compose.yml
Different to other parameters, this parameter can be changed whenever you restart the docker container
init_postgres_host (string, default=db) The hostname of your PostgreSQL database
init_db_port (number, default=5432) The port that your PostgreSQL database listens
See https://github.com/docker-library/docs/tree/master/postgres#environment-variables
Content type
Image
Digest
Size
78.2 MB
Last updated
about 5 years ago
docker pull speendo/djangocms-postgresql