TeamPiped / Piped-Docker

MIT License
46 stars 33 forks source link

[Enhancement] Self hosted option - Docker Swarm with Traefik #7

Closed matt-laird closed 4 months ago

matt-laird commented 3 years ago

Hey Team,

Came across this cool project last night and got a personal instance running using a Swarm with Traefik to link things together. Had to figure out a lot of the container relationships and configs, since the documentation and general project is still getting up to speed. (personally, I would love this project to gain more traction that Invidious as it has a ton of potential)

Below is the contents of the compose:

version: '3.8'

services:
  pipedfrontend:
    image: 1337kavin/piped-frontend:latest
    entrypoint: ash -c 'sed -i s/pipedapi.kavin.rocks/api.yourdomain.com/g /usr/share/nginx/html/js/* && /docker-entrypoint.sh && nginx -g "daemon off;"'
    networks:
      - traefik_public
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]
      labels:
        - "traefik.docker.network=traefik_public"
        - "traefik.http.services.piped-ui.loadbalancer.server.port=80"
        - "traefik.http.routers.piped-ui.entrypoints=https"
        - "traefik.http.routers.piped-ui.rule=Host(`frontend.yourdomain.com`)"

  piped:
    image: 1337kavin/piped:latest
    volumes:
      - ./Piped/config/config.properties:/app/config.properties:ro
    networks:
      - internal
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]

  nginx:
    image: nginx:mainline-alpine
    networks:
      - traefik_public
      - internal
    volumes:
      - ./Piped/config/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./Piped/config/pipedproxy.conf:/etc/nginx/conf.d/pipedproxy.conf:ro
      - ./Piped/config/ytproxy.conf:/etc/nginx/snippets/ytproxy.conf:ro
      - ./Piped/ytproxy:/var/run/ytproxy
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]
      labels:
        - "traefik.docker.network=traefik_public"
        - "traefik.http.services.piped-proxy.loadbalancer.server.port=80"
        - "traefik.http.routers.piped-proxy.entrypoints=https"
        - "traefik.http.routers.piped-proxy.rule=Host(`proxy.yourdomain.com`)"

  ytproxy:
    image: 1337kavin/ytproxy:latest
    networks:
      - internal
    volumes:
      - ./Piped/ytproxy/:/app/socket/
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]

  varnish:
    image: varnish:7.0-alpine
    volumes:
      - ./Piped/config/default.vcl:/etc/varnish/default.vcl:ro
    networks:
      - traefik_public
      - internal
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]
      labels:
        - "traefik.docker.network=traefik_public"
        - "traefik.http.services.piped-api.loadbalancer.server.port=80"
        - "traefik.http.routers.piped-api.entrypoints=https"
        - "traefik.http.routers.piped-api.rule=Host(`api.yourdomain.com`)"

  postgres:
    image: postgres:13-alpine
    volumes:
      - ./Piped/db:/var/lib/postgresql/data
    networks:
      - internal
    environment:
      - POSTGRES_DB=piped
      - POSTGRES_USER=piped
      - POSTGRES_PASSWORD=changeme
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]

networks:
  traefik_public:
    external: true
  internal:
    driver: overlay
    ipam:
      config:
        - subnet: 172.16.25.0/24

Notes:

I'm sure this all can be improved, but I thought it could serve as a good starting point for the multi-container architecture that has been chosen.

Hopefully this can help in some shape or form. Let me know how else I can help with the project.

FireMasterK commented 3 years ago

I honestly don't know much about Traefik, and have never used it 😅

Support for Traefik could be added to this repository/script later, however I need to understand how it works before I touch anything.

If you're still using Nginx, why not just proxy everything to 127.0.0.1:8080 along with the Host header? That should be easier than everything combined!

matt-laird commented 3 years ago

Cool, yeah I understand, just thought I'd share as I know there will be some people that would ask about alternate self-hosted options.

Side question, has there been an official lunch for this project, or is it still getting there? The documentation is very vague.

FireMasterK commented 3 years ago

The documentation is very vague.

This is something that needs work, I'll be working on this shortly since even the Nginx configuration isn't documented yet (and was only recently implemented).

seonwoolee commented 2 years ago

@matt-laird Thank you for your docker-compose.yml! I also use Traefik and I was able to use your docker-compose.yml to run Piped. I don't use Swarm so I just took all of that out, and it works perfectly.

JesseWebDotCom commented 1 year ago

@matt-laird Thank you for your docker-compose.yml! I also use Traefik and I was able to use your docker-compose.yml to run Piped. I don't use Swarm so I just took all of that out, and it works perfectly.

Can you share your compose?

erikderzweite commented 1 year ago

@matt-laird Thank you for your docker-compose.yml! I also use Traefik and I was able to use your docker-compose.yml to run Piped. I don't use Swarm so I just took all of that out, and it works perfectly.

Tried to do that, did not work. Could you please share your compose file?

FireMasterK commented 1 year ago

Hi, I added support for traefik in https://github.com/TeamPiped/Piped-Docker/commit/49b98cbeb3a1d8042ccd384b81976793bcd06a53. You need to have an entrypoint called websecure. You just need to select nginx in the configure script, you'll have a (hopefuly) Traefik compatible docker-compose file.