exoframejs / exoframe

Exoframe is a self-hosted tool that allows simple one-command deployments using Docker
https://exoframejs.github.io/exoframe/
1.14k stars 57 forks source link

Trouble to run services without exoframe but with traefik #304

Closed niklasgrewe closed 3 years ago

niklasgrewe commented 3 years ago

Hi, i want to run a rocketchat instance on my exoframe server using traefik. I am using a docker-compose file looks like this:

version: '3'

services:
  rocketchat:
    image: rocketchat/rocket.chat:latest
    command: >
      bash -c
        "for i in `seq 1 30`; do
          node main.js &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - ./uploads:/app/uploads
    environment:
      - PORT=3000
      - ROOT_URL=https://chat.grewe.io
      - MONGO_URL=mongodb://mongo:27017/rocketchat
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local
      - MAIL_URL=smtp://smtp.mail.com
#       - HTTP_PROXY=http://proxy.domain.com
#       - HTTPS_PROXY=http://proxy.domain.com
    depends_on:
      - mongo
    ports:
      - 3000:3000
    labels:
       - "traefik.enable=true"
       - "traefik.http.middlewares.rocketchat-redirect.redirectscheme.scheme=https"
       - "traefik.http.routers.rocketchat-web.entrypoints=web"
       - "traefik.http.routers.rocketchat-web.middlewares=directus-redirect@docker"
       - "traefik.http.routers.rocketchat-web.rule=Host(`my.domain.com`)"
       - "traefik.http.routers.rocketchat.entrypoints=websecure"
       - "traefik.http.routers.rocketchat.rule=Host(`my.domain.com`)"
       - "traefik.http.routers.rocketchat.tls.certresolver=exoframeChallenge"
       - "traefik.http.services.rocketchat.loadbalancer.server.port=3000"

  mongo:
    image: mongo:4.0
    restart: unless-stopped
    volumes:
     - ./data/db:/data/db
     #- ./data/dump:/dump
    command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
    labels:
      - "traefik.enable=false"

  # this container's job is just run the command to initialize the replica set.
  # it will run the command and remove himself (it will not stay running)
  mongo-init-replica:
    image: mongo:4.0
    command: >
      bash -c
        "for i in `seq 1 30`; do
          mongo mongo/rocketchat --eval \"
            rs.initiate({
              _id: 'rs0',
              members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
    depends_on:
      - mongo

When i try to access the rocketchat instance i get the following results:

http://my.domain.com   -> 404 Not Found
https://my.domain.com  -> Gateway Timeout but valid HTTPS Connection with generated Let's Encrypt Certificate

So where is my issue? Do i need to use the exoframe docker network to get this working correctly? Hope everyone can help me to fix that

yamalight commented 3 years ago

Are you deploying your compose using exoframe cli? If not - then yes, you do need to manually add all your containers to exoframe network.

Your redirect middleware also doesn't look right (unless that's something you've defined in traefik config):

"traefik.http.routers.rocketchat-web.middlewares=directus-redirect@docker"

niklasgrewe commented 3 years ago

@yamalight thanks for quick answer. Perfect it works now. But why i need to add the exoframe network to all containers?

yamalight commented 3 years ago

Don't have to add all of them - just the ones that traefik should pick up (since it monitors that network specifically). If you want to - you can use different network for db, etc. But it does complicate the overall setup then.

niklasgrewe commented 3 years ago

ok thanks for the explanation. Now everything works as expected.

niklasgrewe commented 3 years ago

I reopened this error because I couldn't get another service to run. After some configuration I was able to fix the error myself. Therefore this case is closed again.