Back to the video

Dockerising wagtail projects in 5 minutes - Sævar Öfjörð Magnússon

Transcript

By Sævar Öfjörð Magnússon. From Wagtail Space NL 2022. Published June 30, 2022.

Watch the video Markdown version 460 words · auto-generated · en

Summary

Sævar Öfjörð Magnússon explains how he built a template repository for starting Wagtail projects entirely in Docker. Wanting to keep his host computer free of Python and other project dependencies left him unable to create a normal project locally, so the template provides a Docker container in which he can create one. He clones the template, starts the container, opens a shell with `docker compose exec`, runs `wagtail start` and `manage.py migrate`, then restarts the container with the project’s normal process. The setup also lets users customize the port to avoid conflicts and leaves initial project creation under their control.

Transcript

Automatically transcribed, so expect mistakes in names and technical terms. Filler words are removed.

0:00 Dockerising Wagtail: Motivation and Template

Originally I wanted to do a talk about how I would dock raise a an existing Wagtail project. The backstory is that like in January I got a new computer and we decided to move everything we had for clients. To Docker. So I want to maintain like a clean host computer without any libraries or Python stuff in it so I only use Docker to develop locally. So it turns out that I don't have an existing project on my computer like I couldn't create a base project on my computer because I don't have any of the dependencies.

So it was a kind of a cat's twenty two. So I flipped it so I will show you how I created a small template repository which will allow you to create a Docker Doc Rest Wagtail project in you know a few minutes. But first, this is a mess mistake many rookies do. They don't have the proper attire when working with docs. So you know. Okay, now I'm ready. Yeah, so I created a small template repository which you can use to

1:36 Creating a Project from the Template

generate a product project. So I'm going to use this template I'm going to create a my Wagtail site. That's available. Create the repository from template So now I have the repository. I can clone the repository locally. So I will open up a terminal. Can you see this? No. Yeah. Okay. So I'll go to something like Code git clone repository. So what I would do here is just Docker compose

2:21 Starting the Docker Container

up Port already all located. Yeah, okay. So yeah, I run a lot of Dockers and some Sometimes they conflict. So I have this thing where I can customize the port. So what I do initially is I let the container run in kind of an infinite loop really. It's not doing anything at the moment because when you have an empty container, I didn't want to go the path of like doing everything for you in the beginning.

3:07 Initialising the Wagtail Site

Because you want to control perhaps the name of your project and stuff like that. So I would just do a Docker compose exec Go into a shell and do a wagtail start my site in the current folder. I will I can do a manage migrate. So now I'm gonna stop the container again I'm going to switch it over to the correct process Run it again.

So here it is. Thank you.