Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
13.05k stars 1.5k forks source link

Redis connection doesn't work on docker container. #6687

Open Juliasmatius opened 3 days ago

Juliasmatius commented 3 days ago

Describe the problem

When trying to launch the peertube docker container i get the following crash

https://pastebin.com/xDS3VvGB

I've tried to define redis instance information in .env

# Database / Postgres service configuration
POSTGRES_USER=peertube
POSTGRES_PASSWORD=peertube
# Postgres database name "peertube"
POSTGRES_DB=peertube
# The database name used by PeerTube will be PEERTUBE_DB_NAME (only if set) *OR* 'peertube'+PEERTUBE_DB_SUFFIX
#PEERTUBE_DB_NAME=<MY POSTGRES DB NAME>
#PEERTUBE_DB_SUFFIX=_prod
# Database username and password used by PeerTube must match Postgres', so they are copied:
PEERTUBE_DB_USERNAME=$POSTGRES_USER
PEERTUBE_DB_PASSWORD=$POSTGRES_PASSWORD
PEERTUBE_DB_SSL=false
# Default to Postgres service name "postgres" in docker-compose.yml
PEERTUBE_DB_HOSTNAME=postgres

# 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=127.0.0.1
# If you just want to test PeerTube on local
PEERTUBE_WEBSERVER_PORT=9000
PEERTUBE_WEBSERVER_HTTPS=false
# 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.0/16"]

# Generate one using `openssl rand -hex 32`
PEERTUBE_SECRET=redacted

# E-mail configuration
# If you use a Custom SMTP server
PEERTUBE_SMTP_USERNAME=video@julimiro.eu
PEERTUBE_SMTP_PASSWORD=redacted
# Default to Postfix service name "postfix" in docker-compose.yml
# May be the hostname of your Custom SMTP server
PEERTUBE_SMTP_HOSTNAME=mail.julimiro.eu
PEERTUBE_SMTP_PORT=465
PEERTUBE_SMTP_FROM=video@julimiro.eu
PEERTUBE_SMTP_TLS=true
PEERTUBE_SMTP_DISABLE_STARTTLS=true
PEERTUBE_ADMIN_EMAIL=julimiro@posteo.net

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
PEERTUBE_REDIS_HOSTNAME=redis
PEERTUBE_REDIS_PORT=6379
PEERTUBE_REDIS_AUTH=null

and here's the compose file.

services:
  peertube:
    # If you don't want to use the official image and build one from sources:
    # build:
    #   context: .
    #   dockerfile: ./support/docker/production/Dockerfile.bookworm
    image: chocobozzz/peertube:production-bookworm
    # 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
        ipv6_address: 2001:db8:2::42
    env_file:
      - .env

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

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

  redis:
    image: redis:6-alpine
    volumes:
      - /mnt/hdd/peertube/docker-volume/redis:/data
    restart: "always"

networks:
  default:
    enable_ipv6: true
    ipam:
      driver: default
      config:
      - subnet: 172.18.0.0/16
      - subnet: 2001:db8:2::/64

volumes:
  assets:
  certbot-www:

Additional information

Chocobozzz commented 3 days ago

Can you try to remove PEERTUBE_REDIS_* variables from your env file?

Juliasmatius commented 3 days ago

Sure!

The log for that is https://pastebin.com/8kGbr7RF

Chocobozzz commented 2 days ago

Can you go inside your peertube container and try to ping redis? (ping is not in the peertube container but you can try curl -v redis:6379)

Juliasmatius commented 2 days ago

I seem to be getting a response.

root@v25159:~/docker/peertube# docker exec -it peertube-peertube-1 bash
root@df89efbf35b3:/app# curl -v redis:6379
*   Trying [2001:db8:2::2]:6379...
* Connected to redis (2001:db8:2::2) port 6379 (#0)
> GET / HTTP/1.1
> Host: redis:6379
> User-Agent: curl/7.88.1
> Accept: */*
> 
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server
RJGhugo commented 1 day ago

Hope this solves it: https://github.com/Chocobozzz/PeerTube/commit/f4339cfb72ac80c1c68059496da99797c4a0484b

The IPv6 2001:db8:-Range is for documentation only.

https://datatracker.ietf.org/doc/html/rfc3849

Juliasmatius commented 1 day ago

That change requires line 52 of the compose file to be changed to the container stairs up. I set it to ipv6_address: fdab:e4b3:21a2:ef1b:0000:0000:0000:0123 for testing. But i still get the same error. log

I am also not a 100% sure i modified the compose file correctly so thats here https://pastebin.com/J3wR0CPW