Skip to content

Commit aae82ad

Browse files
committed
Prepare Fly deployment for Mastodon 4.5
Pin the app images and align the Fly upgrade workflow with Mastodon 4.5 so deploys run the required migrations and the docs reflect the new Postgres and Redis prerequisites.
1 parent 7330a6e commit aae82ad

4 files changed

Lines changed: 17 additions & 14 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM tootsuite/mastodon-streaming:v4.4 as streaming
1+
FROM tootsuite/mastodon-streaming:v4.5.7 as streaming
22

3-
FROM tootsuite/mastodon:v4.4
3+
FROM tootsuite/mastodon:v4.5.7
44

55
USER root
66

Dockerfile.redis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM redis:alpine
1+
FROM redis:7-alpine
22
ADD start-redis-server.sh /usr/bin/
33
RUN chmod +x /usr/bin/start-redis-server.sh
44
CMD ["start-redis-server.sh"]

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ fly apps create mastodon-example
2121
### Secrets
2222

2323
```bash
24-
export SECRET_KEY_BASE=$(docker run --rm -it tootsuite/mastodon:latest bin/rake secret)
25-
export OTP_SECRET=$(docker run --rm -it tootsuite/mastodon:latest bin/rake secret)
26-
fly secrets set OTP_SECRET=$OTP_SECRET SECRET_KEY_BASE=$SECRET_KEY_BASE
27-
docker run --rm -e OTP_SECRET=$OTP_SECRET -e SECRET_KEY_BASE=$SECRET_KEY_BASE -it tootsuite/mastodon:latest bin/rake mastodon:webpush:generate_vapid_key | sed 's/\r//' | fly secrets import
24+
export MASTODON_VERSION=v4.5.7
25+
export SECRET_KEY_BASE=$(docker run --rm -it tootsuite/mastodon:$MASTODON_VERSION bin/rake secret)
26+
fly secrets set SECRET_KEY_BASE=$SECRET_KEY_BASE
27+
docker run --rm -e SECRET_KEY_BASE=$SECRET_KEY_BASE -it tootsuite/mastodon:$MASTODON_VERSION bin/rake mastodon:webpush:generate_vapid_key | sed 's/\r//' | fly secrets import
2828
```
2929

3030
### Redis server
@@ -134,15 +134,17 @@ If your instance is getting slow or falling over, you may find [Scaling Mastodon
134134

135135
### Upgrading Mastodon
136136

137-
To upgrade to a new version of Mastodon, change the version number on the first line of `Dockerfile`, and then check the [release notes](https://github.com/mastodon/mastodon/blob/main/CHANGELOG.md) for upgrade instructions.
137+
To upgrade to a new version of Mastodon, update the Mastodon image tags in [`Dockerfile`](./Dockerfile), and then check the [release notes](https://github.com/mastodon/mastodon/blob/main/CHANGELOG.md) for upgrade instructions.
138138

139-
If there are migrations that need to be run, make sure that the release command in [`fly.toml`](./fly.toml) is uncommented.
139+
This repo keeps the Fly release command enabled in [`fly.toml`](./fly.toml), so standard post-deploy migrations run automatically during `fly deploy`.
140+
141+
Before upgrading to Mastodon 4.5.x or newer, make sure your Fly Postgres app is already on PostgreSQL 14 or newer and your Redis app is already on Redis 7 or newer.
140142

141143
If there are migrations that must be run before deploying to avoid downtime, you can run the pre-deploy migrations using a second app. By scaling this app to a VM count of zero, it won't add to our bill, but it will let us run the pre-deploy migrations as a release command before the web processes get the new code.
142144
143145
```bash
144146
fly apps create mastodon-example-predeploy
145-
bin/fly-predeploy secrets set OTP_SECRET=placeholder SECRET_KEY_BASE=placeholder
147+
bin/fly-predeploy secrets set SECRET_KEY_BASE=placeholder
146148
bin/fly-predeploy secrets set $(fly ssh console -C env | grep DATABASE_URL)
147149
bin/fly-predeploy scale memory 1024
148150
bin/fly-predeploy scale count 0

fly.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ swap_size_mb = 1024
88
[[vm]]
99
memory = "1024"
1010

11-
## Uncomment if you are upgrading Mastodon. See README.md for details.
12-
# [deploy]
13-
# release_command = "bin/rails db:migrate"
11+
## Keep standard post-deploy migrations enabled.
12+
## Use fly.predeploy.toml for releases that require pre-deployment migrations.
13+
[deploy]
14+
release_command = "bin/rails db:migrate"
1415

1516
[env]
1617
LOCAL_DOMAIN = "social.python.it"
@@ -52,7 +53,7 @@ swap_size_mb = 1024
5253
# rails = "./overmind start -x rails"
5354
# # If you need to run more sidekiq workers, scale up this group
5455
# # by running `fly scale count N --group sidekiq`
55-
# sidekiq = "bash -c 'bundle exec sidekiq -c $MAX_THREADS -q default,8 -q push,6 -q ingress,4 -q mailers,2 -q pull'"
56+
# sidekiq = "bash -c 'bundle exec sidekiq -c $MAX_THREADS -q default,8 -q push,6 -q ingress,4 -q mailers,2 -q pull,1 -q fasp,1'"
5657
# # The schedule queue can only ever have one worker process at a time
5758
# # by running fly scale count 1 --group schedule
5859
# schedule = "bash -c 'bundle exec sidekiq -c $MAX_THREADS'"

0 commit comments

Comments
 (0)