Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Preserve previous museum image before deploy

Manav Rathiff47e98dcd5d
diff --git a/server/scripts/deploy/README.md b/server/scripts/deploy/README.md
index 92d0dcf468..1e25337533 100644
--- a/server/scripts/deploy/README.md
+++ b/server/scripts/deploy/README.md
@@ -89,3 +89,22 @@ SSH into the instance, and run
```
This'll ask for sudo credentials, pull the latest Docker image, restart the museum service and start tailing the logs (as a sanity check).
+
+## Rollback
+
+The update script tags the currently running image as `museum-prod:previous` before pulling. To roll back:
+
+```sh
+sudo docker tag rg.fr-par.scw.cloud/ente/museum-prod:previous rg.fr-par.scw.cloud/ente/museum-prod:latest
+sudo systemctl restart museum
+```
+
+> [!NOTE]
+>
+> This doesn't work if there are migrations!
+
+To reset the local `latest` back to the registry image, run `./update-and-restart-museum.sh` again, or
+
+```sh
+sudo docker pull rg.fr-par.scw.cloud/ente/museum-prod:latest
+```
diff --git a/server/scripts/deploy/update-and-restart-museum.sh b/server/scripts/deploy/update-and-restart-museum.sh
index f8155c35cd..82bafcb023 100755
--- a/server/scripts/deploy/update-and-restart-museum.sh
+++ b/server/scripts/deploy/update-and-restart-museum.sh
@@ -2,12 +2,15 @@
# This script is meant to be run on the production instances.
#
-# It will pull the latest Docker image, restart the museum process and start
-# tailing the logs as a sanity check.
+# It will tag the old image, pull the latest Docker image, restart museum and
+# start tailing the logs as a sanity check.
set -o errexit
-# The service file also does this, but also pre-pull here to minimize downtime.
+if sudo docker inspect museum >/dev/null 2>&1; then
+ sudo docker tag "$(sudo docker inspect -f '{{.Image}}' museum)" rg.fr-par.scw.cloud/ente/museum-prod:previous
+fi
+
sudo docker pull rg.fr-par.scw.cloud/ente/museum-prod
sudo systemctl restart museum