文章

Docker部署Activity-Relay服务

Docker部署Activity-Relay服务

前言

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

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

具体步骤

拉取仓库

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

编辑配置

进入Activity-Relay目录

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

编辑config.yml修改相关配置

生成actor RSA 证书

ubuntu使用

1
openssl genrsa -traditional | tee actor.pem

centos使用

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

赋予权限600

1
chmod 600 actor.pem

docker-compose配置

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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

构建镜像与运行服务

1
2
docker-compose build
docker-compose up -d

查看容器运行状态

1
docker-compose ps

停止服务

1
docker-compose down

反向代理

1
2
3
4
5
6
7
8
9
10
    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 的中继服务即可

本文由作者按照 CC BY 4.0 进行授权