吐槽部分:这玩意,确实是一个WebP2P的极好的分享方案,但是,官网的文档写的简直是一塌糊涂.文档是基于旧版本写的,而且也不更新.常用的管理功能不是很完善,如果真要拿来用,自己得有足够的相关知识储备来修改和配置,目前来看.只能说自己搭建了好玩,用来收藏一点自己喜欢的颜色视频罢了.反正我每天十分钟,研究了好几天,都没整明白怎么对接AWS S3和MinIO.另外提一嘴,直播端口不仅要开放1935,你还得开放1936端口!


项目地址

官网:https://joinpeertube.org/ (可能要借助魔法才能访问)

Gayhub:https://github.com/Chocobozzz/PeerTube

基于Docker安装

创建目录

mkdir /你的目录/peertube/ 
cd /你的目录/peertube/ 

拉取最新的Docker配置文件

curl https://raw.githubusercontent.com/chocobozzz/PeerTube/master/support/docker/production/docker-compose.yml > docker-compose.yml

这里我给出一下我的docker-compose.yml的配置,因为我本地有安装nginx,为了避免冲突,我去掉了peertube自带的.

docker-compose.yml


services:

  peertube:
    # If you don't want to use the official image and build one from sources:
    # build:
    #   context: .
    #   dockerfile: ./support/docker/production/Dockerfile.bullseye
    image: chocobozzz/peertube:production-bullseye
    # Use a static IP for this container because nginx does not handle proxy host change without reload
    # This container could be restarted on crash or until the postgresql database is ready for connection
    networks:
      default:
        ipv4_address: 172.18.0.42
    env_file:
      - .env

    ports:
     - "1935:1935" # Comment if you don't want to use the live feature
     - "9000:9000" # Uncomment if you use another webserver/proxy or test PeerTube in local, otherwise not suitable for production
    volumes:
      - assets:/app/client/dist
      - ./docker-volume/data:/data
      - ./docker-volume/config:/config
    depends_on:
      - postgres
      - redis
    restart: "always"

  postgres:
    image: postgres:13-alpine
    env_file:
      - .env
    volumes:
      - ./docker-volume/db:/var/lib/postgresql/data
    restart: "always"

  redis:
    image: redis:6-alpine
    volumes:
      - ./docker-volume/redis:/data
    restart: "always"


networks:
  default:
    ipam:
      driver: default
      config:
      - subnet: 172.18.0.0/16

volumes:
  assets:

拉取环境变量env文件`

curl https://raw.githubusercontent.com/Chocobozzz/PeerTube/master/support/docker/production/.env > .env

然后编辑你的docker-compose.yml

根据你自己的情况选择要或者不要的服务

  • webserver:web 服务,供浏览器访问.(如果你已经安装其他web服务,可以不选.另外我不建议你用nginx来反向代理,因为nginx反向代理之后流媒体需要缓存完毕以后才会发送到客户端,所以基本是播放不了的状态.)
  • peertube:核心,你能不选吗?
  • redis:缓存服务,必选.
  • postgres:数据库,必选.
  • postfix:如果你要提供开放式的服务,就选上,如果是自己搭建的好玩,不选.
  • certbot:自动申请证书,没卵用,没有可以选.

然后编辑.env来修改你的数据库信息和域名.

  • <MY POSTGRES USERNAME>
  • <MY POSTGRES PASSWORD>
  • <MY DOMAIN> 不带 https://
  • <MY EMAIL ADDRESS>
  • <MY PEERTUBE SECRET>

这一切都准备好以后,就直接开始跑起来吧:

cd /你的目录/peertube
docker-compose up -d

完成以后可以通过你填写的域名加9000端口来访问了

管理员密码获取

Peertub安装完是不显示什么管理员密码的,搞不太懂.可以通过一下命令在安装目录执行获取到root账号密码

docker-compose logs peertube | grep -A1 root 

或者你直接查看Log文件,找到下面的信息也一样.

#查看日志
cat /你的目录/docker-volume/data/logs/peertube.log
#会输出一些信息,找到如下信息,密码就是xxxxxx
{"message":"Username: root","level":"info","timestamp":"}
{"message":"User password: xxxxxxxxxx","level":"info","timestamp":"}

你也可以选择不用Docker,但是我嫌麻烦,参考这里:https://docs.joinpeertube.org/install-any-os

升级Peertube

拉取最新的镜像

#进入你的目录
cd /你的目录/peertube
#然后拉取最新的包
docker-compose pull

停止删除容器和卷

docker-compose down -v

然后再跑起来

docker-compose up -d

最后提示一下,升级这个我没尝试过啊,毕竟我Docker用的不多,另外Peertube的docker版本的配置文件和常规版本有点不一样,你们如果要操作,建议先随便搭建一个尝试一下,确认没问题再升级,或者做好相关的备份.