Last active
May 14, 2017 15:52
-
-
Save mattintosh4/913c2ec8adc5e34753d6b80ec7a5de7b to your computer and use it in GitHub Desktop.
LXC-Docker-Mastodon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
trap_exit(){ | |
sudo lxc-stop -n mastodon_x || : | |
sudo lxc-destroy -n mastodon_x | |
} | |
trap trap_exit EXIT | |
sudo lxc-create -n mastodon_x -t ubuntu -- -r xenial | |
sudo tee -a /var/lib/lxc/mastodon_x/config <<! | |
lxc.aa_profile = unconfined | |
lxc.cgroup.cpu.shares = 512 | |
! | |
sudo lxc-start -n mastodon_x | |
sudo lxc-attach -n mastodon_x -- bash -ex <<\! | |
echo 'nameserver 8.8.8.8' >>/etc/resolvconf/resolv.conf.d/head | |
echo 'nameserver 8.8.4.4' >>/etc/resolvconf/resolv.conf.d/head | |
resolvconf -u | |
apt-get update | |
apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
software-properties-common \ | |
curl \ | |
linux-image-extra-$(uname -r) \ | |
linux-image-extra-virtual | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt-get update | |
apt-get install -y docker-ce | |
apt-get autoremove | |
curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-$(uname -s)-$(uname -m) >/usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
usermod -aG docker ubuntu | |
! | |
sudo lxc-stop -n mastodon_x | |
sudo lxc-copy -n mastodon_x -N mastodon_0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
git clone https://github.com/tootsuite/mastodon.git | |
tar cf - mastodon | gzip >mastodon.tar.gz | |
cd mastodon | |
git checkout -f remotes/origin/1.3-stable | |
sed -i -e "/^# /s// /" docker-compose.yml | |
cp .env.production.sample \ | |
.env.production | |
docker-compose build | |
set -- $(docker-compose run --rm web rake secret) \ | |
$(docker-compose run --rm web rake secret) \ | |
$(docker-compose run --rm web rake secret) | |
sed -i -e " | |
/^LOCAL_DOMAIN=/ s/=.*/=127.0.0.1/ | |
/^LOCAL_HTTPS=/ s/=.*/false/ | |
/^PAPERCLIP_SECRET=/s/=.*/=$1/ | |
/^SECRET_KEY_BASE=/ s/=.*/=$2/ | |
/^OTP_SECRET=/ s/=.*/=$3/ | |
" .env.production | |
docker-compose run --rm web rails db:migrate | |
docker-compose run --rm web rails assets:precompile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LXC と Docker を使って Mastodon のインスタンスを作る
母艦の Ubuntu で
lxc-docker-mastodon_1.sh
を実行します。スクリプトエリア右上の「Raw」から最新のリビジョンの URL を使用してください。bash <(curl -L https://gist.github.com/mattintosh4/913c2ec8adc5e34753d6b80ec7a5de7b/raw/e02d50deeecf11f784bfea1bc82d91d9376bbe92/lxc-docker-mastodon_1.sh)
ベースとなるコンテナ(mastodon_0)を試験用コンテナ(mastodon_1)としてコピーします。
試験用コンテナを起動して IP アドレスを確認します。
母艦から SSH で試験用コンテナに接続します。SSH のユーザ名/パスワードは ubuntu/ubuntu です。
試験用コンテナ内で
lxc-docker-mastodon_2.sh
を実行します。ここでも URL は最新のリビジョンのものを使用してください。bash <(curl -L https://gist.github.com/mattintosh4/913c2ec8adc5e34753d6b80ec7a5de7b/raw/e02d50deeecf11f784bfea1bc82d91d9376bbe92/lxc-docker-mastodon_2.sh)
~/mastodon
に Mastodon の環境が出来上がるので Docker コンテナを起動します。デーモンとして起動する場合は-d
オプションを使用してください。少し待って
http://試験用コンテナのIPアドレス:3000
にアクセスすれば Mastodon を始めることができます。