Skip to content

Instantly share code, notes, and snippets.

@ykzts
Last active December 20, 2020 16:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ykzts/64e188dc7cd1cf6b98ff98678da5b267 to your computer and use it in GitHub Desktop.
Save ykzts/64e188dc7cd1cf6b98ff98678da5b267 to your computer and use it in GitHub Desktop.
MastodonをDockerでどっかーっと一発で動かすための便利なdocker-compose.ymlです。

MastodonをDockerでどっかーっと一発で動かすための便利なdocker-compose.ymlです。

初回

$ sudo useradd mastodon
$ sudo usermod -aG docker mastodon
$ sudo -u mastodon mkdir -p ~mastodon/live
$ cd ~mastodon/live
$ sudo -u mastodon wget https://gist.github.com/ykzts/64e188dc7cd1cf6b98ff98678da5b267/raw/docker-compose.yml
$ sudo -u mastodon wget https://gist.github.com/ykzts/64e188dc7cd1cf6b98ff98678da5b267/raw/update.sh
$ sudo -u mastodon wget -O .env.production https://github.com/tootsuite/mastodon/raw/v1.2.2/.env.production.sample
$ sudo -u mastodon -e .env.production
$ sudo -u mastodon docker-compose pull
$ sudo -u mastodon docker-compose run --rm web ./bin/rails db:schema:load assets:precompile
$ sudo -u mastodon docker-compose up -d
$ sudo -u mastodon docker-compose scale sidekiq=3
$ cat << __EOS | sudo tee -a /etc/cron.daily/mastodon > /dev/null
#!/bin/sh

cd /home/mastodon/live && sudo -u mastodon docker-compose run --rm web ./bin/rails mastodon:daily > /dev/null
__EOS
$ sudo chmod +x /etc/cron.daily/mastodon

アップデート

$ cd ~mastodon/live
$ sudo -u mastodon -e docker-compose.yml
$ sudo -u mastodon ./update.sh
version: "3.0"
services:
db:
restart: always
image: postgres:alpine
volumes:
- ./postgres:/var/lib/postgresql/data
redis:
restart: always
image: redis:alpine
volumes:
- ./redis:/data
web:
restart: always
image: gargron/mastodon:v1.2.2
env_file: .env.production
command: bundle exec rails s -p 3000 -b 0.0.0.0
ports:
- "3000:3000"
depends_on:
- db
- redis
volumes:
- ./public/assets:/mastodon/public/assets
- ./public/system:/mastodon/public/system
streaming:
restart: always
image: gargron/mastodon:v1.2.2
env_file: .env.production
command: npm run start
ports:
- "4000:4000"
depends_on:
- db
- redis
sidekiq:
restart: always
image: gargron/mastodon:v1.2.2
env_file: .env.production
command: bundle exec sidekiq -q default -q mailers -q pull -q push
depends_on:
- db
- redis
volumes:
- ./public/system:/mastodon/public/system
#!/bin/sh
docker-compose pull
docker-compose down
docker-compose run --rm web ./bin/rails db:migrate assets:precompile
docker-compose up -d
docker-compose scale sidekiq=3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment