群暉(Synology)用docker安裝mastodon

可能需要一點IT背景,至少要先會SSH登入群暉並換成ROOT帳號

前置條件,docker安裝好redis、postgres,這二個一定要確定先在Docker裝好,雖然群暉也有postgres,但不好操作。

開始安裝Mastodon

git clone https://github.com/tootsuite/mastodon.git mastodon

cd 到Mastodon,並且mkdir以下資料夾

mkdir redis
mkdir postgres
mkdir elasticsearch
mkdir public/system

bundle起來

docker-compose run --rm web bundle exec rake mastodon:setup

注意以下的產出資料,要貼到.env.production

創建管理者的時候密碼要記得存檔,不然就…

2024/03/19測試管理員可以一起建了

docker-compose down之後 在docker-compose up -d

確認一下Docker是否都有啟動

當然要記得反向代理

下面是docker-compose.yml,因為我3000port被佔用了,換成3011

version: '3'
services:
  db:
    restart: always
    image: postgres:15-alpine
    shm_size: 256mb
    networks:
      - internal_network
    healthcheck:
      test: ['CMD', 'pg_isready', '-U', 'postgres']
    volumes:
      - ./postgres:/var/lib/postgresql/data
    environment:
      - 'POSTGRES_HOST_AUTH_METHOD=trust'
  redis:
    restart: always
    image: redis:7-alpine
    networks:
      - internal_network
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
    volumes:
      - ./redis:/data
  es:
     restart: always
     image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
     environment:
       - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
       - "cluster.name=es-mastodon"
       - "discovery.type=single-node"
       - "bootstrap.memory_lock=true"
     networks:
        - internal_network
     healthcheck:
        test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
     volumes:
        - ./elasticsearch:/usr/share/elasticsearch/data
     ulimits:
       memlock:
         soft: -1
         hard: -1
  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:
      # prettier-ignore
      test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1']
    ports:
      - '0.0.0.0:3011: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:
      # prettier-ignore
      test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1']
    ports:
      - '0.0.0.0: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
    healthcheck:
      test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]

  ## 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

只是粗略的講一下而已,照步驟走的話也許還會有一些問題吧

不過大家有興趣還是可以嘗試一下。

全文搜索還是不太懂,目標只是讓群暉Synology可以跑Mastodon而已。

chown 1000:1000 -R elasticsearch

docker-compose run --rm web bin/tootctl search deploy

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *