plankanban / planka

The realtime kanban board for workgroups built with React and Redux.
https://planka.app
GNU Affero General Public License v3.0
7.73k stars 718 forks source link

Issue with Docker Compose and Traefik #148

Open h2seo opened 3 years ago

h2seo commented 3 years ago

I wanted to try Planka on docker compose with Traefik but it doesn't seem to work. only error "Bad Gateway"

docker-compose.yml

  planka:
    image: meltyshev/planka:latest
    command: >
      bash -c
        "for i in `seq 1 30`; do
          ./start.sh &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 seconds...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - user-avatars:/app/public/user-avatars
      - project-background-images:/app/public/project-background-images
      - attachments:/app/public/attachments
    ports:
      - 3000:1337
    networks:
    - web
    labels:
      - traefik.backend=planka
      - traefik.frontend.rule=Host:planka.x069.duckdns.org
      - traefik.docker.network=web
      - traefik.port=3000
      - traefik.enable=true

    environment:
      - BASE_URL=http://localhost:3000
      - DATABASE_URL=postgresql://postgres@postgres/planka
      - SECRET_KEY=notsecretkey
    depends_on:
      - postgres

  postgres:
    image: postgres:alpine
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=planka
      - POSTGRES_HOST_AUTH_METHOD=trust

volumes:
  user-avatars:
  project-background-images:
  attachments:
  db-data:
johnchristopher commented 3 years ago

It's a Traefik misconfiguration, the port you tell Traefik to send traffic to is wrong.

Try this:

  labels:
      - traefik.backend=planka
      - traefik.frontend.rule=Host:planka.x069.duckdns.org
      - traefik.docker.network=web
      - traefik.port=1337
      - traefik.enable=true

And you can remove this part unless you want to be able to access planka directly from opened port 3000 on your server:

    ports:
      - 3000:1337

If you still get bad gateway it means Traefik can't find a port on the container, so expose it (to Traefik and end points on your docker web network) but normally planka exposes this port by default:

expose:
  - "3000"

Make sure the traefik container can talk with the docker web network:

$ docker connect web traefik

edit: here's a working docker-compose I wrote from the one you supplied. I am using Traefik2 with self-signed certificates on localhost but planka service don't need to change:

---
networks:
  default:
    external:
      name: planka

services:
  planka:
    image: meltyshev/planka:latest
    command: >
      bash -c
        "for i in `seq 1 30`; do
          ./start.sh &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 seconds...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - user-avatars:/app/public/user-avatars
      - project-background-images:/app/public/project-background-images
      - attachments:/app/public/attachments
    labels:
      - traefik.enable=true
      - traefik.http.routers.planka.entrypoints=https
      - traefik.http.routers.planka.rule=Host(`planka.localhost`)
      - traefik.http.routers.planka.tls=true
      - traefik.http.services.planka.loadbalancer.server.port=1337
    environment:
      - BASE_URL=https://planka.localhost # am using https but http is fine if you configured traefik to use http
      - DATABASE_URL=postgresql://postgres@postgres/planka
      - SECRET_KEY=notsecretkey
    depends_on:
      - postgres

  postgres:
    image: postgres:alpine
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=planka
      - POSTGRES_HOST_AUTH_METHOD=trust

version: 3.4

volumes:
  user-avatars:
  project-background-images:
  attachments:
  db-data:

Then:

$ docker network create planka ; docker network connect planka traefik ; docker-compose up -d ;