Lemmy server setup on lemmy.cafe
Lemmy server setup on lemmy.cafe
docker compose
I'm using a v2
- notice the lack of a dash between docker
and compose
.
I've recently learnt of the default filenames docker compose
is trying to
source upon invocation and decided to give it a try. The files are:
- compose.yml
- compose.override.yml
I have split the default docker-compose.yml
that lemmy
comes with into 2
parts - compose.yml
holds pict-rs
, postfix
and, in my case,
gatus
. compose.override.yml
is responsible for lemmy services only. This is
what the files contain:
compose.override.yml
is actually a hardlink to the currently active
deployment. I have two separate files - compose-green.yml
and
compose-blue.yml
. This allows me to prepare and deploy an upgrade to lemmy
while the old version is still running.
The only constant different between the two is the IP address I use to expose them to the host. I've tried using ports, but found that it's much easier to follow it in my mind by sticking to the ports and changing the bound IP.
I also have two nginx
configs to reflect the different IP for green
/blue
deployments, but pasting the whole config here would be a tad too much.
No-downtime upgrade
Let's say green
is the currently active deployment. In that case - edit the compose-blue.yml
file to change the version of lemmy on all 4 components - lemmy, federation, tasks and ui. Then bring down the tasks
container from the active deployment, activate the whole of blue
deployment and link it to be the compose.override.yml
. Once the tasks
container is done with whatever tasks it's supposed to do - switch over the nginx
config. Et voilĂ - no downtime upgrade is live!
Now all that's left to do is tear down the green
containers.
undefined
docker compose down lemmy-tasks-green docker compose -f compose-blue.yml up -d ln -f compose-blue.yml compose.override.yml # Wait for tasks to finish ln -sf /etc/nginx/sites-available/lemmy.cafe-blue.conf /etc/sites-enabled/lemmy.cafe.conf nginx -t && nginx -s reload docker compose -f compose-green.yml down lemmy-green lemmy-federation-green lemmy-tasks-green lemmy-ui-green
lemmy.hjson
I have also multiplied lemmy.hjson
to provide a bit more control.
I suspect it might be possible to remove pict-rs
and/or email
config from some of them, but honestly it's not a big deal and I haven't had enough time, yet, to look at it.
Future steps
I'd like to script the actual switch-over - it's really trivial, especially since most of the parts are there already. All I'd really like is apply strict failure mode on the script and see how it behaves; do a few actual upgrades.
Once that happens - I'll post it here.
So long and thanks for all the fish!