VMware搭建docker mastodon

本文档介绍了如何在VMware CentOS 7.6环境下配置Docker,并按照GitHub官方文档及多个教程,使用qq邮箱的SMTP授权码进行配置。详细步骤包括安装Docker、配置Nginx、自签发HTTPS证书,以及启动和访问Mastodon应用。过程中参考了多个技术博客和文章。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境 VMware
CentOS 7.6
[root@warship ~]# docker version
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:22 2018
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false
按照github官方文档

[root@warship live]# git clone https://github.com/tootsuite/mastodon.git live
[root@warship live]# cd ~/live
[root@warship live]# git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
[root@warship live]# vim docker-compose.yml
注释所有build .
[root@warship live]# cat docker-compose.yml 
version: '3'
services:

  db:
    restart: always
    image: postgres:9.6-alpine
    networks:
      - internal_network
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]
    volumes:
      - ./postgres:/var/lib/postgresql/data

  redis:
    restart: always
    image: redis:5.0-alpine
    networks:
      - internal_network
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
    volumes:
      - ./redis:/data

#  es:
#    restart: always
#    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.3
#    environment:
#      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
#    networks:
#      - internal_network
#    healthcheck:
#      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
#    volumes:
#      - ./elasticsearch:/usr/share/elasticsearch/data

  web:
    #build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
    networks:
      - external_network
      - internal_network
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy=off localhost:3000/api/v1/instance || exit 1"]
    ports:
      - "127.0.0.1:3000:3000"
    depends_on:
      - db
      - redis
#      - es
    volumes:
      - ./public/system:/mastodon/public/system

  streaming:
    #build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: node ./streaming
    networks:
      - external_network
      - internal_network
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy=off localhost:4000/api/v1/streaming/health || exit 1"]
    ports:
      - "127.0.0.1:4000:4000"
    depends_on:
      - db
      - redis

  sidekiq:
    #build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec sidekiq
    depends_on:
      - db
      - redis
    networks:
      - external_network
      - internal_network
    volumes:
      - ./public/system:/mastodon/public/system
## Uncomment to enable federation with tor instances along with adding the following ENV variables
## http_proxy=http://privoxy:8118
## ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
#  tor:
#    image: sirboops/tor
#    networks:
#      - external_network
#      - internal_network
#
#  privoxy:
#    image: sirboops/privoxy
#    volumes:
#      - ./priv-config:/opt/config
#    networks:
#      - external_network
#      - internal_network

networks:
  external_network:
  internal_network:
    internal: true
[root@warship live]# cp .env.production.sample .env.production
[root@warship live]# chown -R 991:991 public


[root@warship live]# docker-compose run --rm web bundle exec rake mastodon:setup
Starting live_redis_1 ... done
Starting live_db_1    ... done


Your instance is identified by its domain name. Changing it afterward will break things.
Domain name: mymedia.com

Single user mode disables registrations and redirects the landing page to your public profile.
Do you want to enable single user mode? No

Are you using Docker to run Mastodon? Yes

PostgreSQL host: db
PostgreSQL port: 5432
Name of PostgreSQL database: postgres
Name of PostgreSQL user: 1
Password of PostgreSQL user: Aborting. Bye!
[root@warship live]# docker-compose run --rm web bundle exec rake mastodon:setup
Starting live_redis_1 ... done
Starting live_db_1    ... done
Your instance is identified by its domain name. Changing it afterward will break things.
Domain name: mymedia.com

Single user mode disables registrations and redirects the landing page to your public profile.
Do you want to enable single user mode? No

Are you using Docker to run Mastodon? Yes

PostgreSQL host: db
PostgreSQL port: 5432
Name of PostgreSQL database: postgres
Name of PostgreSQL user: postgres
Password of PostgreSQL user:
Database configuration works! ?

Redis host: redis
Redis port: 6379
Redis password:
Redis configuration works! ?

Do you want to store uploaded files on the cloud? No

Do you want to send e-mails from localhost? No
SMTP server: smtp.qq.com
SMTP port: 587
SMTP username:你的qq号@qq.com
SMTP password:由网页邮箱配置页面生成的
SMTP authentication: plain
SMTP OpenSSL verify mode: none 必须选这个
E-mail address to send e-mails "from": 你的qq号@qq.com(必须写这个 默认的不能用)
Send a test e-mail with this configuration right now? Yes
Send test e-mail to: 测试邮件的接收邮箱

This configuration will be written to .env.production
Save configuration? Yes
Below is your configuration, save it to an .env.production file outside Docker:
把下面内容写入.env.production 之前以为是自动写的,后来发现需要手动写入文件.env.production
# Generated with mastodon:setup on 2019-09-02 05:36:12 UTC

LOCAL_DOMAIN=mymedia.com
SINGLE_USER_MODE=false
SECRET_KEY_BASE=6a74668b033ec0357052ba5046805e80733dbe565b7d570774490ac978b6b8bd87aaa57471608bdeba955ac499b28c1edb4b291da45630f59086a0062667680d
OTP_SECRET=28431a3559ed5ea84b153c9abc7c12fe524b1cd9e37cf72f62934764eae73e6d1175796f6175fbdf456f6f1d08d02f3b12e0c10b40e89a525b2e62e6f1ef868e
VAPID_PRIVATE_KEY=aY9GGtmNGBrdqbXXz7OrMZP8CqIIx86D71YHC5DQ_tU=
VAPID_PUBLIC_KEY=BBJ6l-N7YAaUVN3ulcnABb-SRWzpuJfEBDb6AdU6gI1TuSUNuAeLAYyTULbnL0ilg0RwlcQPmGZf-nSZjsm0DjQ=
DB_HOST=db
DB_PORT=5432
DB_NAME=postgres
DB_USER=postgres
DB_PASS=
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=
SMTP_SERVER=smtp.qq.com
SMTP_PORT=587
SMTP_LOGIN=你的qq号@qq.com
SMTP_PASSWORD=由网页邮箱配置页面生成的
SMTP_AUTH_METHOD=plain
SMTP_OPENSSL_VERIFY_MODE=none
SMTP_FROM_ADDRESS=你的qq号@qq.com
Now that configuration is saved, the database schema must be loaded.
If the database already exists, this will erase its contents.
#令开一个终端写完.env.production后继续点击下一步
Prepare the database now? Yes
Running `RAILS_ENV=production rails db:setup
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值