Files
quartz-research-note/content/Mastodonのアップデートでいちいちdocker-compose.ymlを一時的に書き換えない.md

45 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#tips
普通、dockerで運用するときはMastodonのリポジトリをクローンしてきて、`docker-compose.yml``build`をコメントアウトすることで、リポジトリからコンテナイメージをpullするように変える。
ただこの場合、バージョンアップデートの際に`git stash && git fetch && git checkout <version>` するとこんな感じにconflictが発生する。(ここでは4.2から4.2.5にダウングレードしてる)
```yml
web:
<<<<<<< Updated upstream
build: .
image: ghcr.io/mastodon/mastodon:v4.2.5
=======
# build: .
image: ghcr.io/mastodon/mastodon:v4.2.6
>>>>>>> Stashed changes
restart: always
```
そこで、`docker-compose.yml`とは別に`docker-compose.override.yml`というのを置いておくと、特定のキーを上書きしてくれる。
最近まで、この上書き機能では特定のエントリをコメントアウトするような操作はできなかったが、docker-compose v2.18.0以降で`!reset`というのを置いておくとできるようになった。
[docker-compose.override.yml で 打ち消し定義 ができるようになった。](https://zenn.dev/iitenkida7/articles/91b88ca76e98c7)
そこでこんなsudo apt-get upgrade docker-compose-plugin`docker-compose.override.yml`を作る。
```yml
web:
image: ghcr.io/mastodon/mastodon:latest
build: !reset
#depends_on: #必要に応じて
# - es
streaming
image: ghcr.io/mastodon/mastodon:latest
build: !reset
sidekiq
image: ghcr.io/mastodon/mastodon:latest
build: !reset
```
こうすれば、更新する時は`docker-compose pull&& docker-compose down && docker-compose up -d`1つでよくなる。(compose自体に更新が入ったり、.env.productionとかに変更があったり、`rake:db migrate`する必要がある場合もあるので、基本はリリースノートを読んでから!)