Docker部署Activity-Relay服务

前言

最初部署的Activity-Relay服务由于是在宿主机上工作,前段时间由于宿主机机房重启了机器 使Relay服务莫名其妙的不能启动

于是这次使用便携易用的Docker来部署服务,记录一下以备用

具体步骤

拉取仓库

git clone https://github.com/yukimochi/Activity-Relay.git -b v2.0.0

编辑配置

进入Activity-Relay目录

cd Activity-Relay
cp config.yml.example config.yml

编辑config.yml修改相关配置

生成actor RSA 证书

ubuntu使用

openssl genrsa -traditional | tee actor.pem

centos使用

openssl genrsa -out actor.pem 1024 | tee actor.pem

赋予权限600

chmod 600 actor.pem

docker-compose配置

这里需开放端口用以反向代理

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

  worker:
    container_name: worker
    build: .
    image: yukimochi/activity-relay
    working_dir: /var/lib/relay
    restart: always
    init: true
    command: relay worker
    volumes:
      - "./actor.pem:/var/lib/relay/actor.pem"
      - "./config.yml:/var/lib/relay/config.yml"
    depends_on:
      - redis

  server:
    container_name: relay
    build: .
    image: yukimochi/activity-relay
    working_dir: /var/lib/relay
    restart: always
    init: true
    ports:
      - "8080:8080"
    command: relay server
    volumes:
      - "./actor.pem:/var/lib/relay/actor.pem"
      - "./config.yml:/var/lib/relay/config.yml"
    depends_on:
      - redis

构建镜像与运行服务

docker-compose build
docker-compose up -d

查看容器运行状态

docker-compose ps

停止服务

docker-compose down

反向代理

    location = /inbox {
        proxy_pass http://127.0.0.1:8080; 
        proxy_pass_request_headers on; 
        proxy_set_header Host $http_host; 
    }
    location = /actor {
        proxy_pass http://127.0.0.1:8080; 
        proxy_pass_request_headers on; 
        proxy_set_header Host $http_host; 
    }

完成

https://relay.jiong.us/inbox
加入mastodon 的中继服务即可