Over the weekend I found out about a CMS software written on top of Django called Wagtail.
The installation instructions promise an easy path. Just run:
pip install wagtail
Since I guard my global pip pretty carefully in order to reduce version collisions and whatnot, my first inclination was to see if I can test this from within a Docker container.
To start the experiment within a Docker container using Python, I start with:
mkdir wagtail
cd wagtail
docker run -it --rm \
--mount type=bind,source="%CD%",target=/wagtail \
python:3.7-buster /bin/bash
I use “%CD%
” because I’m on Windows. If I were on Linux/Mac, I suppose it would be something like “${PWD}
” instead.
So once in, I install and initialize per the instructions from Getting started — Wagtail Documentation 3.0.1 documentation:
cd /wagtail
pip install wagtail
wagtail start hahaha
Interestingly, that wagtail start
command, in addition to generating a bunch of files typical for a Django app, also created a Dockerfile
.
So maybe the installer may already have some Docker support in mind?
Reading through it and spending more time than I expected to get to work, here are the steps to:
- Get a Wagtail project set up from scratch using Docker without having to install any Python on the host.
- Use a volume from the host for the app AND the SQLite DB so that they can be conveniently backed up and transferred (e.g. pushed up to some code repository like Github or SVN).
Generate a new Wagtail project
Pretty much what I had above:
mkdir wagtail
cd wagtail
docker run -it --rm \
--mount type=bind,source="%CD%",target=/wagtail \
python:3.7-buster /bin/bash
cd /wagtail
pip install wagtail
wagtail start hahaha
exit
I’m using “hahaha
” as my project name. Substitute as needed. Also: %CD%
should be ${PWD}
for Linux/Mac.
Build the Image
cd hahaha docker build -t hahaha .
Fix up file permissions (Windows only)
Since the app should be run by the user wagtail:wagtail
, fix up the permissions on the files.
For some reason this is not done correctly for Windows despite the command in Dockerfile
, so a manual step is required:
docker run -it --rm \
--mount type=bind,source="%CD%",target=/app \
--user root hahaha /bin/bash
chown -R wagtail:wagtail .
exit
Set Up the App
This is typical Django setup stuff:
docker run -it --rm \
--mount type=bind,source="%CD%",target=/app \
hahaha /bin/bash
python manage.py migrate
python manage.py createsuperuser
exit
The above will create the db.sqlite3
file to be used for the app and also set up an admin user to be used to sign into the app.
Run The App
Finally, to run the app:
docker run -it --rm -p 8000:8000 \
--mount type=bind,source="%CD%",target=/app hahaha
The -it --rm
arguments are optional, but they help in stopping and cleaning up the container during development.
The site can be accessed at, of course, http://localhost:8000/
. To manage it, use the superuser created earlier to get into the Admin Interface.
Worker Timeout
And now to actually start playing around with Wagtail….
So far I’m seeing a lot of errors when requesting pages in the Admin site. They look like this:
[2022-08-01 01:48:15 +0000] [10] [CRITICAL] WORKER TIMEOUT (pid:12) [2022-08-01 01:48:15 +0000] [12] [INFO] Worker exiting (pid: 12) [2022-08-01 01:48:15 +0000] [13] [INFO] Booting worker with pid: 13 [2022-08-01 01:48:58 +0000] [10] [CRITICAL] WORKER TIMEOUT (pid:13) [2022-08-01 01:48:58 +0000] [13] [INFO] Worker exiting (pid: 13) [2022-08-01 01:48:58 +0000] [14] [INFO] Booting worker with pid: 14 [2022-08-01 01:49:56 +0000] [10] [CRITICAL] WORKER TIMEOUT (pid:14) [2022-08-01 01:49:56 +0000] [14] [INFO] Worker exiting (pid: 14) [2022-08-01 01:49:56 +0000] [15] [INFO] Booting worker with pid: 15 [2022-08-01 01:50:34 +0000] [10] [CRITICAL] WORKER TIMEOUT (pid:15) [2022-08-01 01:50:34 +0000] [15] [INFO] Worker exiting (pid: 15) [2022-08-01 01:50:34 +0000] [16] [INFO] Booting worker with pid: 16