tiangolo / dockerswarm.rocks

Docker Swarm mode rocks! Ideas, tools and recipes. Get a production-ready, distributed, HTTPS served, cluster in minutes, not weeks.
https://dockerswarm.rocks/
1.09k stars 126 forks source link

Adding thelounge to swarm results in 404 error #8

Closed ghost closed 4 years ago

ghost commented 5 years ago

Hello, Sebastián,

we e-mailed a few days ago. Unfortunately I didn't get any further to start thelounge (https://hub.docker.com/r/thelounge/thelounge/), but like colleagues here I get the 404 error from traefik.

My thelounge.yml file looks like this:

version: '3.3'

services:
  thelounge:
    image: thelounge/thelounge:latest
    volumes:
      - thelounge:/data
      #- ~/data/thelounge:/var/opt/thelounge
    ports:
        - "4000:4000"
    labels:
      # - traefik.backend=thelounge
      - traefik.enable=true
      - traefik.frontend.rule=Host:${DOMAIN}
      - traefik.port=4000
      - traefik.docker.network=traefik-public
      - traefik.tags=traefik-public
      # Traefik service that listens to HTTP
      - traefik.redirectorservice.frontend.entryPoints=http
      - traefik.redirectorservice.frontend.redirect.entryPoint=https
      # Traefik service that listens to HTTPS
      - traefik.webservice.frontend.entryPoints=https      
    networks:
      #- web
      - traefik-public

networks:
  traefik-public:
    external: true

volumes:
  thelounge:

What did I do wrong? Can anyone please help me with my problem?

Edit: I also tried:

version: '3.3'

services:
  thelounge:
    image: thelounge/thelounge:latest
    volumes:
      - thelounge:/data
    labels:
      # - traefik.backend=thelounge
      - traefik.enable=true
      - traefik.frontend.rule=Host:${DOMAIN}
      - traefik.port=4000
      - traefik.docker.network=traefik-public
      - traefik.tags=traefik-public
      # Traefik service that listens to HTTP
      - traefik.redirectorservice.frontend.entryPoints=http
      - traefik.redirectorservice.frontend.redirect.entryPoint=https
      # Traefik service that listens to HTTPS
      - traefik.webservice.frontend.entryPoints=https      
    networks:
      #- web
      - traefik-public

networks:
  traefik-public:
    external: true

volumes:
  thelounge:

Also the 404 error appears. :-(

ghost commented 5 years ago

I also tried this but also this results in a 404 error:

version: '3.3'

services:
  thelounge:
    image: thelounge/thelounge:latest
    volumes:
      - thelounge-data:/data
      #- ~/data/thelounge:/var/opt/thelounge
    networks:
      - traefik-public
    deploy:
      placement:
        constraints:
          - node.role == manager
          - node.labels.thelounge.thelounge-data == true
    labels:
      # - traefik.backend=thelounge
      - traefik.enable=true
      - traefik.frontend.rule=Host:${DOMAIN}
      - traefik.port=4000
      - traefik.docker.network=traefik-public
      - traefik.tags=traefik-public
      # Traefik service that listens to HTTP
      - traefik.redirectorservice.frontend.entryPoints=http
      - traefik.redirectorservice.frontend.redirect.entryPoint=https
      # Traefik service that listens to HTTPS
      - traefik.webservice.frontend.entryPoints=https      
    networks:
      #- web
      - traefik-public

networks:
  traefik-public:
    external: true

volumes:
  thelounge-data:

any ideas what I have done wrong?

Thanks!

rayrrr commented 5 years ago

Try indenting your whole labels block so that it is under a deploy block (with the deploy block at the same indentation level as in your last example). That got it working for me!

ghost commented 5 years ago

Thanks you mean like:


version: '3.3'

services:
  thelounge:
    image: thelounge/thelounge:latest
    volumes:
      - thelounge-data:/data
      #- ~/data/thelounge:/var/opt/thelounge
    networks:
      - traefik-public
    labels:
      # - traefik.backend=thelounge
      - traefik.enable=true
      - traefik.frontend.rule=Host:${DOMAIN}
      - traefik.port=4000
      - traefik.docker.network=traefik-public
      - traefik.tags=traefik-public
      # Traefik service that listens to HTTP
      - traefik.redirectorservice.frontend.entryPoints=http
      - traefik.redirectorservice.frontend.redirect.entryPoint=https
      # Traefik service that listens to HTTPS
      - traefik.webservice.frontend.entryPoints=https      
    networks:
      #- web
      - traefik-public
    deploy:
      placement:
        constraints:
          - node.role == manager
          - node.labels.thelounge.thelounge-data == true

networks:
  traefik-public:
    external: true

volumes:
  thelounge-data:
rayrrr commented 5 years ago

No that is not what I meant.

tiangolo commented 5 years ago

@noobcoder1983 what @rayrrr is saying is that you should put the labels inside the deploy key, something like:

version: '3.3'

services:
  thelounge:
    image: thelounge/thelounge:latest
    volumes:
      - thelounge-data:/data
      #- ~/data/thelounge:/var/opt/thelounge
    networks:
      - traefik-public
    networks:
      #- web
      - traefik-public
    deploy:
      labels:
        # - traefik.backend=thelounge
        - traefik.enable=true
        - traefik.frontend.rule=Host:${DOMAIN}
        - traefik.port=4000
        - traefik.docker.network=traefik-public
        - traefik.tags=traefik-public
        # Traefik service that listens to HTTP
        - traefik.redirectorservice.frontend.entryPoints=http
        - traefik.redirectorservice.frontend.redirect.entryPoint=https
        # Traefik service that listens to HTTPS
        - traefik.webservice.frontend.entryPoints=https      
      placement:
        constraints:
          - node.role == manager
          - node.labels.thelounge.thelounge-data == true

networks:
  traefik-public:
    external: true

volumes:
  thelounge-data:

Also, as your app seems to be running on port 9000 you probably should declare it as such:

version: '3.3'

services:
  thelounge:
    image: thelounge/thelounge:latest
    volumes:
      - thelounge-data:/data
      #- ~/data/thelounge:/var/opt/thelounge
    networks:
      - traefik-public
    networks:
      #- web
      - traefik-public
    deploy:
      labels:
        # - traefik.backend=thelounge
        - traefik.enable=true
        - traefik.frontend.rule=Host:${DOMAIN}
        - traefik.port=9000
        - traefik.docker.network=traefik-public
        - traefik.tags=traefik-public
        # Traefik service that listens to HTTP
        - traefik.redirectorservice.frontend.entryPoints=http
        - traefik.redirectorservice.frontend.redirect.entryPoint=https
        # Traefik service that listens to HTTPS
        - traefik.webservice.frontend.entryPoints=https      
      placement:
        constraints:
          - node.role == manager
          - node.labels.thelounge.thelounge-data == true

networks:
  traefik-public:
    external: true

volumes:
  thelounge-data:
ghost commented 5 years ago

Ok thank you very much for your hints. I will try that :-) When the lounge uses that port and another container is using that port too. What could be the best way to edit thelounge port in the config.js?

tiangolo commented 5 years ago

See my response here: https://github.com/tiangolo/dockerswarm.rocks/issues/4#issuecomment-491513714

ghost commented 5 years ago

Thanks!

ghost commented 5 years ago

Nope that does not help. I tried this:

export NODE_ID=$(docker info -f '{{.Swarm.NodeID}}')
docker node update --label-add thelounge.thelounge-data=true $NODE_ID

with the new .yml file you posted above. Error 404 appears again. :-(

I'm desperate and I really don't know what to do.

tiangolo commented 5 years ago

@noobcoder1983 I think I have a gift for you :gift:

https://dockerswarm.rocks/thelounge/

ghost commented 5 years ago

@tiangolo Thank you so much for your efforts and for the gift. So I was probably close when I compare the compose files. Well, just next to it is also over.

Oh, and it works fine. Hm if I can make it to get run Gitea (https://hub.docker.com/r/gitea/gitea)?

tiangolo commented 5 years ago

Yep, the process would be similar for Gitea.

ghost commented 5 years ago

Hmm I tried that:

version: '3.3'

services:
  app:
    image: gitea/gitea:latest
    volumes:
      - gitea-data:/data
    networks:
      - traefik-public
    deploy:
      placement:
        constraints:
          - node.labels.gitea.gitea-data == true
      labels:
    - traefik.frontend.rule=Host:${DOMAIN}
        - traefik.enable=true
        - traefik.port=9000
        - traefik.tags=traefik-public
        - traefik.docker.network=traefik-public
        # Traefik service that listens to HTTP
        - traefik.redirectorservice.frontend.entryPoints=http
        - traefik.redirectorservice.frontend.redirect.entryPoint=https
        # Traefik service that listens to HTTPS
        - traefik.webservice.frontend.entryPoints=https
      #enviroment:
        - USER_UID=1000
        - USER_GID=1000
      #ports:
    - "2221:22"
networks:
  traefik-public:
    external: true

volumes:
  gitea-data:

But I am always getting the error:

Bad gateway from traefik

ghost commented 5 years ago

Oh had the wrong port with 3000 it works, my failure.

And here the correct gitea.yml file:

version: '3.3'

services:
  app:
    image: gitea/gitea:latest
    volumes:
      - gitea-data:/data
    networks:
      - traefik-public
    deploy:
      placement:
        constraints:
          - node.labels.gitea.gitea-data == true
      labels:
    - traefik.frontend.rule=Host:${DOMAIN}
        - traefik.enable=true
        - traefik.port=3000
        - traefik.tags=traefik-public
        - traefik.docker.network=traefik-public
        # Traefik service that listens to HTTP
        - traefik.redirectorservice.frontend.entryPoints=http
        - traefik.redirectorservice.frontend.redirect.entryPoint=https
        # Traefik service that listens to HTTPS
        - traefik.webservice.frontend.entryPoints=https
      #enviroment:
        - USER_UID=1000
        - USER_GID=1000
      #ports:
    - "2221:22"
networks:
  traefik-public:
    external: true

volumes:
  gitea-data:

Maybe you want to add it to your website. After deploying go to gitea instance and click on register to activate admin account for further usage.

tiangolo commented 5 years ago

Great! I'll add Gitea later (unless a PR comes first :grin: ).

ghost commented 5 years ago

Ok cool thanks. Hmm PR?

tiangolo commented 5 years ago

A Pull Request: https://help.github.com/en/articles/creating-a-pull-request

ghost commented 5 years ago

Excuse my unknowing :scream:

I hope in the future I will learn more and more about github. :smile:

So with a pull request I could add my knowledge to your repo?

tiangolo commented 5 years ago

No worries!

Yep, with a pull request you could add it.

ghost commented 5 years ago

Oh ok good to know. Maybe I test some other services for the swarm tutorials.

tiangolo commented 4 years ago

I think we can close this issue now, right @noobcoder1983 ?

ghost commented 4 years ago

Thanks for aksing me, yes we can close it.