This is part of my series on building out my WordPress CDN plugin code.
While I'm trying to figure out my Stripe integration issues (Described here), I realised that I needed to convert my code base over to Docker in order to continue development on my new laptop.
I had originally developed it using Vagrant + VirtualBox, with Ansible for provisioning my servers. However, my new laptop is a Macbook that uses the newer M1 silicon. This makes my code will not run on my laptop, as VirtualBox is an x86 emulator, and not compatible with an ARM processor.
Not to worry, this will be a good excercise in converting over to Docker, which I can then use to form a containerised deployment architecture on one of the Cloud providers (still TBC).
To begin with, I used this Google Cloud example Dockerfile as a starting point, and basically copied my django code into that container.
This has been a relatively painless process, and more-or-less worked straight out of the box. I did have a few areas that needed attention in order to work:
.env
file to set environment variables that I don't want to include in source control.uWSGI
, but have moved over to gunicorn
, as that's the interface used in the example Dockerfile and seemed to be the easier option. This was a simple drop-in replacement, and didn't require any edits to my codeAll-in-all, a simple transition for the back-end API.
When it comes time to deploy this API, I will put a productio NGINX box in front of the django app, using a simple proxy-pass configuration. Alternatively, the Cloud provider I choose might have some sort of API gateway-style functionality that I can use in place of NGINX, but we'll cross that bridge when we get to it.