|
@@ -0,0 +1,73 @@
|
|
|
+# Production Deployments
|
|
|
+
|
|
|
+Museum runs using Docker + systemd on production instances, load balanced via
|
|
|
+Cloudflare.
|
|
|
+
|
|
|
+This document outlines how we ourselves deploy museum. Note that this is very
|
|
|
+specific to our use case, and while this might be useful as an example, this is
|
|
|
+likely overkill for simple self hosted deployments.
|
|
|
+
|
|
|
+## Overview
|
|
|
+
|
|
|
+We use museum's Dockerfile to build images which we then run on vanilla Ubuntu
|
|
|
+servers (+ Docker installed). For ease of administration, we wrap Docker
|
|
|
+commands to start/stop/update it in a systemd service.
|
|
|
+
|
|
|
+* The production machines are vanilla Ubuntu instances, with Docker and Promtail
|
|
|
+installed.
|
|
|
+
|
|
|
+* There is a [GitHub action](../../../.github/workflows/server-release.yml) to
|
|
|
+ build museum Docker images using its Dockerfile.
|
|
|
+
|
|
|
+* We wrap the commands to start and stop containers using these images in a
|
|
|
+ systemd service.
|
|
|
+
|
|
|
+* We call this general concept of standalone Docker images that are managed
|
|
|
+using systemd as "services". More examples and details
|
|
|
+[here](../../../infra/services/README.md).
|
|
|
+
|
|
|
+* So museum is a "service". You can see its systemd unit definition in
|
|
|
+ [museum.service](museum.service)
|
|
|
+
|
|
|
+* On the running instance, we use `systemctl start|stop|status museum` to manage
|
|
|
+ it.
|
|
|
+
|
|
|
+* The service automatically updates itself on each start. There's also a
|
|
|
+ convenience [script](update-and-restart-museum.sh) that pre-downloads the
|
|
|
+ latest image to further reduce the delay during a restart.
|
|
|
+
|
|
|
+## Installation
|
|
|
+
|
|
|
+To bring up an additional museum node:
|
|
|
+
|
|
|
+* Prepare the instance to run our services
|
|
|
+
|
|
|
+* Setup [promtail](../../../infra/services/promtail/README.md), [prometheus and node-exporter](../../../infra/services/prometheus/README.md) services
|
|
|
+
|
|
|
+* Add credentials
|
|
|
+
|
|
|
+ sudo mkdir -p /root/museum/credentials
|
|
|
+ sudo tee /root/museum/credentials/tls.cert
|
|
|
+ sudo tee /root/museum/credentials/tls.key
|
|
|
+ sudo tee /root/museum/credentials/pst-service-account.json
|
|
|
+ sudo tee /root/museum/credentials/fcm-service-account.json
|
|
|
+ sudo tee /root/museum/credentials.yaml
|
|
|
+
|
|
|
+* Copy the service definition and restart script to the new instance. The
|
|
|
+ restart script can remain in the ente user's home directory. Move the service
|
|
|
+ definition to its proper place.
|
|
|
+
|
|
|
+ scp </path-to-museum>/scripts/museum.service <instance>:
|
|
|
+ scp update-and-restart-museum.sh <instance>:
|
|
|
+
|
|
|
+ sudo mv museum.service /etc/systemd/system
|
|
|
+ sudo systemctl daemon-reload
|
|
|
+
|
|
|
+## Starting
|
|
|
+
|
|
|
+SSH into the instance, and run
|
|
|
+
|
|
|
+ ./update-and-restart-museum.sh
|
|
|
+
|
|
|
+This'll ask for sudo credentials, pull the latest Docker image, restart the
|
|
|
+museum service and start tailing the logs (as a sanity check).
|