Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Last active August 26, 2018 17:58
Show Gist options
  • Save mamemomonga/36b7b74e29b900e58608ac00152d2f6e to your computer and use it in GitHub Desktop.
Save mamemomonga/36b7b74e29b900e58608ac00152d2f6e to your computer and use it in GitHub Desktop.
Raspberry Pi の Docker で Mastodon の Docker Imaege を作成する

Raspberry Pi の Docker で Mastodon の Docker Imaege を作成する

新バージョン: https://github.com/mamemomonga/docker-rpi-mastodon-build

DockerHub: https://hub.docker.com/u/mamemomonga/

Docker のインストール

$ curl https://get.docker.com/ | sh
$ sudo sh -c 'usermod -a -G docker $SUDO_USER'

再ログイン

念のためスワップを有効にする

$ sudo fallocate -l 4G /swap
$ sudo chmod 600 /swap
$ sudo mkswap /swap
$ sudo swapon /swap

node と rubyのビルド

$ mkdir docker-app
$ cd docker-app

$ cat > builds1.sh << 'EOS'
mkdir node
cd node
wget https://raw.githubusercontent.com/nodejs/docker-node/72dd945d29dee5afa73956ebc971bf3a472442f7/8/alpine/Dockerfile
docker build -t mamemomonga/rpi-node:8.11.3-alpine .
cd ..

mkdir ruby
cd ruby
wget https://raw.githubusercontent.com/docker-library/ruby/c43fef8a60cea31eb9e7d960a076d633cb62ba8d/2.4/alpine3.6/Dockerfile
docker build -t mamemomonga/rpi-ruby:2.4.4-alpine3.6 .
cd ..
EOS

$ nohup bash builds1.sh &
$ tail -f nohup.out

寝る → 起きる → どうやらうまくできたようなので

Docker Hubで公開する。

$ docker login
$ docker push mamemomonga/rpi-ruby
$ docker push mamemomonga/rpi-node

次にマストドンのビルド

$ sudo apt install git
$ git clone https://github.com/tootsuite/mastodon.git
$ cd mastodon
$ git checkout v2.4.3

Dockerfileの以下を書き換え

(v2.4.3ではnodeはいらなかったようだ...)

$ vim Dockerfile

FROM ruby:2.4.4-alpine3.6
↓
FROM mamemomonga/rpi-ruby:2.4.4-alpine3.6

ビルド

$ nohup docker build -t mamemomonga/rpi-mastodon:v2.4.3 . &
$ tail -f nohup.out

追記

こうしたほう最新Stableバージョンを追いかけるので。

$ export MASTODON_VER=$(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
$ echo $MASTODON_VER
v2.4.5
$ git checkout $MASTODON_VER
$ perl -i.orig -nlpE 's#\QFROM ruby:2.4.4-alpine3.6\E#FROM mamemomonga/rpi-ruby:2.4.4-alpine3.6#' Dockerfile
$ docker build -t mamemomonga/armhf-mastodon:$MASTODON_VER .

寝る → 起きる → どうやらうまくできたようなので公開。

$ docker push mamemomonga/rpi-mastodon:v2.4.3

しかしここまでつくって、docker-composeで動かすには redisとpostgresqlのビルドも必要と気づく。

せっかくなんで

postgresql, redis のビルドもする。

エラーなければ公開まで自動でやる。

$ cat > builds2.sh << 'EOS'
mkdir postgres
cd postgres
wget https://raw.githubusercontent.com/docker-library/postgres/master/9.6/alpine/Dockerfile
wget https://raw.githubusercontent.com/docker-library/postgres/master/9.6/alpine/docker-entrypoint.sh
docker build -t mamemomonga/rpi-postgres:9.6-alpine .
docker push mamemomonga/rpi-postgres:9.6-alpine
cd ..

mkdir redis
cd redis
wget https://raw.githubusercontent.com/docker-library/redis/master/4.0/alpine/Dockerfile
wget https://raw.githubusercontent.com/docker-library/redis/master/4.0/alpine/docker-entrypoint.sh
docker build -t mamemomonga/rpi-redis:4.0-alpine .
docker push mamemomonga/rpi-redis:4.0-alpine
cd ..
EOS

$ nohup sh -eux builds2.sh &
$ tail -f nohup.out

晩ご飯をたべる。なんかうまくできてたので

docker-composeのビルド

$ git clone https://github.com/docker/compose.git
$ cd compose
$ git checkout 1.22.0
$ nohup sh -c 'docker build -t mamemomonga/rpi-docker-compose:1.22.0 -f Dockerfile.armhf . && docker push mamemomonga/rpi-docker-compose:1.22.0' &
$ tail -f nohup.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment