infra-vintage/mastodon
2023-03-15 11:42:16 +01:00
..
backups Init mastodon.pub.solar 2022-06-04 20:46:19 +02:00
keybase Init mastodon.pub.solar 2022-06-04 20:46:19 +02:00
nginx Init mastodon.pub.solar 2022-06-04 20:46:19 +02:00
.envrc Add .envrc for mastodon, setting correct triton 2023-02-19 19:04:57 +01:00
.gitignore Init mastodon.pub.solar 2022-06-04 20:46:19 +02:00
docker-compose.yml mastodon: fix sign_up route, redirect to sign_in 2023-03-15 11:42:16 +01:00
README.md Init mastodon.pub.solar 2022-06-04 20:46:19 +02:00

pub.solar mastodon

https://mastodon.pub.solar

Upgrading

This section assumes you edited docker-compose.yml and bumped the mastodon docker image version tag

# check current trailing number of mastodon containers
# current_container_index
docker ps | grep -E "sidekiq|streaming|web"

# make a DB backup and copy it to your local machine
docker exec -it matrix-postgres bash

# in shell in matrix-postgres container:
pg_dump -U mastodon -d mastodon_production -W -f /root/mastodon_db_backup-$(date +%F).sql
exit

# copy backup to local machine
docker cp matrix-postgres:/root/mastodon_db_backup-$(date +%F).sql .

# download new mastodon docker images
docker-compose --project-name blue-mastodon pull

# run pre-update migrations
docker-compose run \
  --rm \
  -e SKIP_POST_DEPLOYMENT_MIGRATIONS=true \
  web \
    rails db:migrate

# create new containers with new mastodon version
docker-compose --project-name blue-mastodon up \
  --detach \
  --scale web=2 \
  --scale streaming=2 \
  --scale sidekiq=2 \
  --no-recreate

# stop containers with old mastodon version
docker stop \
  blue-mastodon_web_($current_container_index - 1) \
  blue-mastodon_streaming_($current_container_index - 1) \
  blue-mastodon_sidekiq_($current_container_index - 1)

# run post-deployment migrations
docker-compose run --rm web rails db:migrate

# clean up containers with old mastodon version
docker rm \
  blue-mastodon_web_($current_container_index - 1) \
  blue-mastodon_streaming_($current_container_index - 1) \
  blue-mastodon_sidekiq_($current_container_index - 1)

Todos:

  • implement automatic backups, they are only done manually during upgrades at the moment
  • switch proxy from nginx-dehydrated to caddy - done