You can get latest configurations and files from official Mastodon repository on GitHub where you can find docker-compose.yml
and .env.production
as well.
To generate hash codes using rake secret
and other configuration files, you will need Ruby libraries installed; but it is possible to keep the host machine clean with running your commands inside a temporary container based on Mastodon image. Just attach to the shell using the command below and run the following scripts, to achieve their goals.
docker run -ti --entrypoint /bin/bash ghcr.io/mastodon/mastodon:v4.2.0
You may enter the commands in the available bash:
bin/rails db:create
rake secret
rake mastodon:webpush:generate_vapid_key
The first command will generate the database, second one will return secret and the last one will generate webpush hash strings.
Copy and paste contents of the .env.production
file from repo, and write it to a file with your preferred name. Personally I will not store my Docker environment files in a dot file, because I do a lot of migrations, and dot
files can increase human error due to their hidden file manager attribute. If you agree, the docker-compose should link to env
instead of .env.production
.
![](https://blog.gordarg.com/wp-content/uploads/2023/11/image.png)
At last, if only the docker-compose.yml
is grabbed (and not the whole repo) remove those lines pointing to local Dockerfile
for build in the .yml
.
![](https://blog.gordarg.com/wp-content/uploads/2023/11/image-2.png)
There are optional configurations such as memory over-commit for Redis. When the Redis is up, run docker cp my_mastodon_container:/etc/sysctl.conf sysctl.conf
, this will create a Linux systemctl
config file based on Redis image, then prepend vm.overcommit_memor
y=1 to the file and map from the .yml
like ./sysctl.conf:/etc/sysctl.conf:ro
.
![](https://blog.gordarg.com/wp-content/uploads/2023/11/image-3.png)