Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matt-laird opened this issue Sep 29, 2021 · 7 comments
Closed

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

matt-laird opened this issue Sep 29, 2021 · 7 comments

Comments

@matt-laird
Copy link

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:

  • The traefik_public network is created external to this stack that serves as the ingest network, this may be different for other people.
  • Nginx is still used in this stack to serve the proxy, in the limited time I had I thought leaving this was the best option.
  • Additional changes were made to the config files in this repo's template folder.
    • config.properties - Changed host names and DB credentials.
    • pipedproxy.conf - Changed API host name.

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
Copy link
Member

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
Copy link
Author

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.

@matt-laird matt-laird changed the title Self hosted option - Docker Swarm with Traefik [Enhancement] Self hosted option - Docker Swarm with Traefik Sep 30, 2021
@FireMasterK
Copy link
Member

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
Copy link

@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
Copy link

@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
Copy link

@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
Copy link
Member

Hi, I added support for traefik in 49b98cb. 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.

@Bnyro Bnyro closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants