Mastodon docker notes (Modified)
原文
修改自: literal
$ git clone https://github.com/tootsuite/mastodon
$ cd mastodon
$ git checkout <你钟意的版本>
# 初始化数据库
$ docker run \
-d
--name bootstrap-postgres # 容器名字(建议改短一点)
-e POSTGRES_USER=mastodon # 数据库用户
-e POSTGRES_PASSWORD=<password> # 密码
-e POSTGRES_DB=mastodon_production # 数据库名字
-v /.../postgres:/var/lib/postgresql/data
# 储存卷 主机:容器 注意要写绝对路径,不知道提前 pwd 看一下 postgres 是指当前你签出代码的项目根文件夹创建一个 postgres 的目录,容器的数据库目录映射出来
postgres:9.6-alpine
# 查看结果
$ docker ps -a
# 检查输出
$docker logs bootstrap-postgres
# 没问题了删掉容器(数据库目录映射出来了)
$ docker stop bootstrap-postgres # 正常退出
$ docker rm bootstrap-postgres
我打算这里开始魔改
$ docker-compose build
$ docker-compose run --rm web bundle exec rake mastodon:setup
跟着教程输入信息,最后会往屏幕打印内容
他会问你是否用 docker: 是
数据库和缓存的主机名就是 docker-compose.yml 里写的服务名
要改的也就数据库名字,用户,密码
编译资源: 是
添加管理员: 否(你环境没法配,数据库连不上)
拷贝下来
$ cp .env.production.sample .env.production
$ ${EDITOR} .env.production
# 把上面的信息弄进去
$ docker-compose up -d db
$ docker-compose logs db # 检查输出
我根本不懂 ruby 不好意思
输出说要加一个环境变量,我加了就能用了
$ docker-compose run -e 不记得了=true --rm web bundle exec rake db:setup
$ docker-compose run --rm web bin/tootctl accounts create <用户名> --email <邮箱> --confirmed --role admin
$ cp /源码目录/dist/nginx.conf /etc/nginx/sites-available/mastodon
$ ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon
$ ${EDITOR} //etc/nginx/sites-available/mastodon
$ nginx -t # 检查配置
$ systemctl restart nginx
修改 server_name <这里>,改成你的域名 其他不要动
$ docker-compose up -d
$ docker-compose down # 关闭服务 (真的是太占内存了)
Mastodon docker notes (Modified)
每个人都有属于自己的一片森林,也许我们从来不曾走过,但它一直在那里,总会在那里。迷失的人迷失了,相逢的人会再相逢。愿这里,成为属于你的小森林。