1 ############# begin setup mastodon ##############
3 # main doc is Docker-Guide.md in docs repo
5 # I'd like to try gnu social just cuz of gnu, but it's not being
6 # well maintained, for example, simple pull requests
8 # https://git.gnu.io/gnu/gnu-social/merge_requests/143
9 # and I submitted my own bugs, basic docs are broken
10 # https://git.gnu.io/gnu/gnu-social/issues/269
12 # note, docker required, but we installed it earlier
14 # i subscrubed to https://github.com/docker/compose/releases.atom
15 # to see release notes.
16 # i had some problems upgrading. blew things away with
18 # docker rmi $(docker images -q)
20 # when running docker-compose run, kernel stack traces are printed to the journal.
21 # things seem to succeed, google says nothing, so ignoring them.
22 curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-$(uname -s)-$(uname -m) | s dd of=/usr/local/bin/docker-compose
23 s chmod +x /usr/local/bin/docker-compose
28 i clone https://github.com/tootsuite/mastodon
30 # subbed to atom feed to deal with updates
31 git checkout $(git tag | grep -v rc | tail -n1)
33 # per instructions, uncomment redis/postgres persistence in docker-compose.yml
34 sed -i 's/^#//' docker-compose.yml
36 cat >.env.production <<'EOF'
45 LOCAL_DOMAIN=mast.iankelling.org
50 SMTP_SERVER=mail.iankelling.org
53 SMTP_FROM_ADDRESS=notifications@mast.iankelling.org
54 SMTP_DOMAIN=mast.iankelling.org
55 SMTP_DELIVERY_METHOD=smtp
58 for key in PAPERCLIP_SECRET SECRET_KEY_BASE OTP_SECRET; do
59 # 1 minute 7 seconds to run this docker command
60 # to generate a secret, and it has ^M chars at the end. wtf. really dumb
61 printf "%s=%s\n" $key "$(docker-compose run --rm web rake secret|dos2unix|tail -n1)" >>.env.production
64 while read -r domain _ pass; do
65 if [[ $domain == mail.iankelling.org ]]; then
67 # remove the username part
69 printf "SMTP_PASSWORD=%s\n" "$pass" >>.env.production
72 done < <(s cat /etc/mailpass)
74 echo "$0: error, failed to find mailpass domain for mastadon"
78 # docker compose makes an interface named like br-8f3e208558f2. we need mail to
80 if ! s /sbin/iptables -t nat -C PREROUTING -i br-+ -p tcp -m tcp --dport 25 -j DNAT --to-destination 10.8.0.4:25; then
81 s /sbin/iptables -t nat -A PREROUTING -i br-+ -p tcp -m tcp --dport 25 -j DNAT --to-destination 10.8.0.4:25
84 docker-compose run --rm web rake mastodon:webpush:generate_vapid_key | grep -E '^VAPID_PUBLIC_KEY=|^VAPID_PRIVATE_KEY=' >> .env.production
85 logq docker-compose run --rm web rake db:migrate
86 docker-compose run --rm web rails assets:precompile
88 # avatar failed to upload, did
89 # docker logs mastodon_web_1
90 # google lead me to this
91 s chown -R 991:991 public/system
93 # docker daemon takes care of starting on boot.
96 s a2enmod proxy_wstunnel headers
97 web-conf -f 3000 - apache2 mast.iankelling.org <<'EOF'
99 RequestHeader set X-Forwarded-Proto "https"
100 ProxyPass /500.html !
101 ProxyPass /oops.png !
102 ProxyPass /api/v1/streaming/ ws://localhost:4000/
103 ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
104 ErrorDocument 500 /500.html
105 ErrorDocument 501 /500.html
106 ErrorDocument 502 /500.html
107 ErrorDocument 503 /500.html
108 ErrorDocument 504 /500.html
112 ############### !!!!!!!!!!!!!!!!!
113 ############### manual steps:
115 # only following a few people atm, so not bothering to figure out backups
116 # when mastodon has not documented it at all.
121 # johns@status.fsf.org
123 # sign in page is at https://mast.iankelling.org/auth/sign_in
124 # register as iank, then
125 # https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Administration-guide.md
126 # docker-compose run --rm web bundle exec rails mastodon:make_admin USERNAME=iank
128 ############# end setup mastodon ##############