From b9af7bd11c54787b32ea25a24b59c7e35bcef7a5 Mon Sep 17 00:00:00 2001 From: A Date: Tue, 11 Mar 2025 09:09:10 -0700 Subject: [PATCH] Add peertube --- conf/caddy/Caddyfile.tmpl | 8 ++++ conf/compose/peertube.docker-compose.yml | 48 +++++++++++++++++++++++ conf/peertube/environment | 49 ++++++++++++++++++++++++ install.sh | 21 +++++++++- 4 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 conf/compose/peertube.docker-compose.yml create mode 100644 conf/peertube/environment diff --git a/conf/caddy/Caddyfile.tmpl b/conf/caddy/Caddyfile.tmpl index 854e851..6747351 100644 --- a/conf/caddy/Caddyfile.tmpl +++ b/conf/caddy/Caddyfile.tmpl @@ -41,6 +41,14 @@ matrix.{$DWEB_DOMAIN}:8448 { reverse_proxy http://synapse:8008 } +peertube.{$DWEB_DOMAIN}:1935, https://peertube.{$DWEB_DOMAIN}:1935 { + reverse_proxy http://peertube-back:1935 +} + +peertube.{$DWEB_DOMAIN}, https://peertube.{$DWEB_DOMAIN} { + reverse_proxy http://peertube-back:9010 +} + social.{$DWEB_DOMAIN}, http://social.{$DWEB_ONION} { root * /srv/mastodon/public diff --git a/conf/compose/peertube.docker-compose.yml b/conf/compose/peertube.docker-compose.yml new file mode 100644 index 0000000..e77719e --- /dev/null +++ b/conf/compose/peertube.docker-compose.yml @@ -0,0 +1,48 @@ +volumes: + peertube_data: + peertube_config: + peertube_db: + peertube_redis: + +networks: + peertube-int: + +services: + peertube-back: + image: chocobozzz/peertube:production-bookworm + env_file: ../peertube/environment + ports: + - "127.0.0.1:1935:1935" + - "127.0.0.1:9010:9000" + volumes: + # Remove the following line if you want to use another webserver/proxy or test PeerTube in local + # - assets:/app/client/dist + - peertube_data:/data + - peertube_config:/config + depends_on: + - peertube-postgres + - peertube-redis + networks: + - peertube-int + - back + restart: "always" + + peertube-postgres: + image: postgres:13-alpine + env_file: ../peertube/environment + environment: + - 'POSTGRES_HOST_AUTH_METHOD=trust' + volumes: + - peertube_db:/var/lib/postgresql/data + networks: + - peertube-int + restart: "always" + + peertube-redis: + image: redis:6-alpine + volumes: + - peertube_redis:/data + networks: + - peertube-int + restart: "always" + diff --git a/conf/peertube/environment b/conf/peertube/environment new file mode 100644 index 0000000..774f9ed --- /dev/null +++ b/conf/peertube/environment @@ -0,0 +1,49 @@ +# Database / Postgres service configuration +POSTGRES_USER=postgres +POSTGRES_PASSWORD= +# Postgres database name "peertube" +POSTGRES_DB=peertube +# Database username and password used by PeerTube must match Postgres', so they are copied: +PEERTUBE_DB_USERNAME=postgres +PEERTUBE_DB_PASSWORD=$POSTGRES_PASSWORD +PEERTUBE_DB_SSL=false +# Default to Postgres service name "postgres" in docker-compose.yml +PEERTUBE_DB_HOSTNAME=peertube-postgres + +PEERTUBE_REDIS_HOSTNAME=peertube-redis + +# PeerTube server configuration +# If you test PeerTube in local: use "peertube.localhost" and add this domain to your host file resolving on 127.0.0.1 +PEERTUBE_WEBSERVER_HOSTNAME=REPLACEME +# If you just want to test PeerTube on local +PEERTUBE_WEBSERVER_PORT=443 +PEERTUBE_WEBSERVER_HTTPS=true +# If you need more than one IP as trust_proxy +# pass them as a comma separated array: +PEERTUBE_TRUST_PROXY=["127.0.0.1", "loopback", "172.18.0.1/32"] + +# Generate one using `openssl rand -hex 32` +PEERTUBE_SECRET= + +# E-mail configuration +# If you use a Custom SMTP server +PEERTUBE_SMTP_USERNAME=changeme +PEERTUBE_SMTP_PASSWORD=changeme +# Default to Postfix service name "postfix" in docker-compose.yml +# May be the hostname of your Custom SMTP server +PEERTUBE_SMTP_HOSTNAME= +PEERTUBE_SMTP_PORT=475 +PEERTUBE_SMTP_FROM= +PEERTUBE_SMTP_TLS=true +PEERTUBE_SMTP_DISABLE_STARTTLS=true +PEERTUBE_ADMIN_EMAIL=changeme@example.com + +PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PUBLIC="public-read" +PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PRIVATE="private" + +#PEERTUBE_LOG_LEVEL=info + +# /!\ Prefer to use the PeerTube admin interface to set the following configurations /!\ +#PEERTUBE_SIGNUP_ENABLED=true +#PEERTUBE_TRANSCODING_ENABLED=true +#PEERTUBE_CONTACT_FORM_ENABLED=true diff --git a/install.sh b/install.sh index 99563c1..9d3242d 100755 --- a/install.sh +++ b/install.sh @@ -139,6 +139,16 @@ mastodon_config () { docker volume rm -f masto_data_tmp } +peertube_config () { + printf "${YELLOW}## Generating Peertube config${NC}\n" + + PEERTUBE_SECRET=$(openssl rand -hex 32) + + sed -i "s/REPLACEME/$DWEB_DOMAIN/" $DCOMMS_DIR/conf/peertube/environment + sed -i "s/PEERTUBE_SECRET=/PEERTUBE_SECRET=$PEERTUBE_SECRET/" $DCOMMS_DIR/conf/peertube/environment + +} + mau_config () { printf "${YELLOW}## Generating mau bot config${NC}\n" docker run --rm --mount type=bind,src=$(readlink -f $DCOMMS_DIR/conf/mau),dst=/data dock.mau.dev/maubot/maubot:v0.3.1 1>&2 >/dev/null @@ -193,7 +203,8 @@ main() { "2" "Element & Synapse" ON \ "3" "Ceno Bridge" ON \ "4" "Maubot" OFF \ - "5" "Mastodon" OFF 3>&1 1>&2 2>&3) + "5" "Mastodon" OFF \ + "6" "Peertube" OFF 3>&1 1>&2 2>&3) if [ -z "$CHOICES" ]; then echo "No option was selected (user hit Cancel or unselected all options)" @@ -226,6 +237,10 @@ main() { COMPOSE_FILES+="-f ./conf/compose/mastodon.docker-compose.yml " MASTO=true ;; + "6") + COMPOSE_FILES+="-f ./conf/compose/peertube.docker-compose.yml " + PEERTUBE=true + ;; *) echo "Unsupported item $CHOICE!" >&2 exit 1 @@ -250,7 +265,6 @@ main() { detect_connectivity - mkdir -p $DCOMMS_DIR/images if [[ "${HUB_REACHABLE}" == true ]]; then di=1 printf "${GREEN}### Grabbing images from Docker Hub.${NC}\n" @@ -286,6 +300,9 @@ main() { if [[ "${MASTO}" == true ]]; then mastodon_config fi + if [[ "${PEERTUBE}" == true ]]; then + peertube_config + fi echo "sudo DWEB_ONION=$DWEB_ONION DWEB_DOMAIN=$DWEB_DOMAIN DWEB_FRIENDLY_DOMAIN=$DWEB_FRIENDLY_DOMAIN docker compose $COMPOSE_FILES up -d" >> $DCOMMS_DIR/run.sh chmod +x $DCOMMS_DIR/run.sh printf "${GREEN} dComms succesfully installed! Start your services by running 'run.sh' in $DCOMMS_DIR.${NC}\n"