angristan / feedbin-docker

Self-host your own Feedbin RSS reader in Docker
MIT License
245 stars 34 forks source link

Camo and Web Unhealthy With Traefik #77

Open conor-f opened 3 years ago

conor-f commented 3 years ago

Followed the instructions in the README, then added some labels in the compose for accessing web and other endpoints and tried start it all up. Camo and Web are unhealthy:

➜  feedbin git:(feedbin) ✗ sudo docker-compose ps
        Name                       Command                   State              Ports       
--------------------------------------------------------------------------------------------
feedbin-camo            npm start                        Up (unhealthy)   8081/tcp          
feedbin-elasticsearch   /docker-entrypoint.sh elas ...   Up (healthy)     9200/tcp, 9300/tcp
feedbin-extract         node app/server.js               Up                                 
feedbin-image           bundle exec foreman start        Up                                 
feedbin-memcached       docker-entrypoint.sh memcached   Up               11211/tcp         
feedbin-minio           /usr/bin/docker-entrypoint ...   Up (healthy)     9000/tcp          
feedbin-minio-create    mc                               Exit 1                             
feedbin-postgres        docker-entrypoint.sh postgres    Up (healthy)     5432/tcp          
feedbin-redis           docker-entrypoint.sh redis ...   Up (healthy)     6379/tcp          
feedbin-refresher       bundle exec foreman start        Up                                 
feedbin-web             bundle exec rails s --port ...   Up (unhealthy)   3000/tcp          
feedbin-workers         foreman start                    Up               3000/tcp          
➜  feedbin git:(feedbin) ✗ sudo docker-compose logs feedbin-camo   
Attaching to feedbin-camo
feedbin-camo             | npm info it worked if it ends with ok
feedbin-camo             | npm info using npm@5.3.0
feedbin-camo             | npm info using node@v8.4.0
feedbin-camo             | npm info lifecycle camo@2.3.0~prestart: camo@2.3.0
feedbin-camo             | npm info lifecycle camo@2.3.0~start: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | > camo@2.3.0 start /opt/camo
feedbin-camo             | > node server.js
feedbin-camo             | 
feedbin-camo             | SSL-Proxy running on 8081 with node:v8.4.0 pid:16 version:2.3.0.
feedbin-camo             | npm info lifecycle camo@2.3.0~poststart: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | ┌──────────────────────────────────────────────────────────┐
feedbin-camo             | │                 npm update check failed                  │
feedbin-camo             | │           Try running with sudo or get access            │
feedbin-camo             | │           to the local update config store via           │
feedbin-camo             | │ sudo chown -R $USER:$(id -gn $USER) /nonexistent/.config │
feedbin-camo             | └──────────────────────────────────────────────────────────┘
feedbin-camo             | npm info ok 
feedbin-camo             | npm info it worked if it ends with ok
feedbin-camo             | npm info using npm@5.3.0
feedbin-camo             | npm info using node@v8.4.0
feedbin-camo             | npm info lifecycle camo@2.3.0~prestart: camo@2.3.0
feedbin-camo             | npm info lifecycle camo@2.3.0~start: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | > camo@2.3.0 start /opt/camo
feedbin-camo             | > node server.js
feedbin-camo             | 
feedbin-camo             | SSL-Proxy running on 8081 with node:v8.4.0 pid:16 version:2.3.0.
feedbin-camo             | npm info lifecycle camo@2.3.0~poststart: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | ┌──────────────────────────────────────────────────────────┐
feedbin-camo             | │                 npm update check failed                  │
feedbin-camo             | │           Try running with sudo or get access            │
feedbin-camo             | │           to the local update config store via           │
feedbin-camo             | │ sudo chown -R $USER:$(id -gn $USER) /nonexistent/.config │
feedbin-camo             | └──────────────────────────────────────────────────────────┘
feedbin-camo             | npm info ok 
feedbin-camo             | npm info it worked if it ends with ok
feedbin-camo             | npm info using npm@5.3.0
feedbin-camo             | npm info using node@v8.4.0
feedbin-camo             | npm info lifecycle camo@2.3.0~prestart: camo@2.3.0
feedbin-camo             | npm info lifecycle camo@2.3.0~start: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | > camo@2.3.0 start /opt/camo
feedbin-camo             | > node server.js
feedbin-camo             | 
feedbin-camo             | SSL-Proxy running on 8081 with node:v8.4.0 pid:17 version:2.3.0.
feedbin-camo             | npm info lifecycle camo@2.3.0~poststart: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | ┌──────────────────────────────────────────────────────────┐
feedbin-camo             | │                 npm update check failed                  │
feedbin-camo             | │           Try running with sudo or get access            │
feedbin-camo             | │           to the local update config store via           │
feedbin-camo             | │ sudo chown -R $USER:$(id -gn $USER) /nonexistent/.config │
feedbin-camo             | └──────────────────────────────────────────────────────────┘
feedbin-camo             | npm info ok 
feedbin-camo             | npm info it worked if it ends with ok
feedbin-camo             | npm info using npm@5.3.0
feedbin-camo             | npm info using node@v8.4.0
feedbin-camo             | npm info lifecycle camo@2.3.0~prestart: camo@2.3.0
feedbin-camo             | npm info lifecycle camo@2.3.0~start: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | > camo@2.3.0 start /opt/camo
feedbin-camo             | > node server.js
feedbin-camo             | 
feedbin-camo             | SSL-Proxy running on 8081 with node:v8.4.0 pid:17 version:2.3.0.
feedbin-camo             | npm info lifecycle camo@2.3.0~poststart: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | ┌──────────────────────────────────────────────────────────┐
feedbin-camo             | │                 npm update check failed                  │
feedbin-camo             | │           Try running with sudo or get access            │
feedbin-camo             | │           to the local update config store via           │
feedbin-camo             | │ sudo chown -R $USER:$(id -gn $USER) /nonexistent/.config │
feedbin-camo             | └──────────────────────────────────────────────────────────┘
feedbin-camo             | npm info ok 
feedbin-camo             | npm info it worked if it ends with ok
feedbin-camo             | npm info using npm@5.3.0
feedbin-camo             | npm info using node@v8.4.0
feedbin-camo             | npm info lifecycle camo@2.3.0~prestart: camo@2.3.0
feedbin-camo             | npm info lifecycle camo@2.3.0~start: camo@2.3.0
feedbin-camo             | 
feedbin-camo             | > camo@2.3.0 start /opt/camo
feedbin-camo             | > node server.js
feedbin-camo             | 
feedbin-camo             | SSL-Proxy running on 8081 with node:v8.4.0 pid:16 version:2.3.0.
➜  feedbin git:(feedbin) ✗ sudo docker-compose logs feedbin-web  
Attaching to feedbin-web
feedbin-web              | => Booting Puma
feedbin-web              | => Rails 6.1.4 application starting in production 
feedbin-web              | => Run `bin/rails server --help` for more startup options
feedbin-web              | I, [2021-07-14T16:26:34.100744 #1]  INFO -- honeybadger: ** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=4.8.0 framework=rails level=1 pid=1
feedbin-web              | Puma starting in single mode...
feedbin-web              | * Puma version: 5.3.2 (ruby 2.7.3-p183) ("Sweetnighter")
feedbin-web              | *  Min threads: 5
feedbin-web              | *  Max threads: 5
feedbin-web              | *  Environment: production
feedbin-web              | *          PID: 1
feedbin-web              | * Listening on http://0.0.0.0:3000
feedbin-web              | Use Ctrl-C to stop
feedbin-web              | - Gracefully stopping, waiting for requests to finish
feedbin-web              | Exiting
feedbin-web              | => Booting Puma
feedbin-web              | => Rails 6.1.4 application starting in production 
feedbin-web              | => Run `bin/rails server --help` for more startup options
feedbin-web              | I, [2021-07-14T16:30:19.312310 #1]  INFO -- honeybadger: ** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=4.8.0 framework=rails level=1 pid=1
feedbin-web              | Puma starting in single mode...
feedbin-web              | * Puma version: 5.3.2 (ruby 2.7.3-p183) ("Sweetnighter")
feedbin-web              | *  Min threads: 5
feedbin-web              | *  Max threads: 5
feedbin-web              | *  Environment: production
feedbin-web              | *          PID: 1
feedbin-web              | * Listening on http://0.0.0.0:3000
feedbin-web              | Use Ctrl-C to stop
feedbin-web              | - Gracefully stopping, waiting for requests to finish
feedbin-web              | Exiting
feedbin-web              | => Booting Puma
feedbin-web              | => Rails 6.1.4 application starting in production 
feedbin-web              | => Run `bin/rails server --help` for more startup options
feedbin-web              | I, [2021-07-14T16:30:45.402806 #1]  INFO -- honeybadger: ** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=4.8.0 framework=rails level=1 pid=1
feedbin-web              | Puma starting in single mode...
feedbin-web              | * Puma version: 5.3.2 (ruby 2.7.3-p183) ("Sweetnighter")
feedbin-web              | *  Min threads: 5
feedbin-web              | *  Max threads: 5
feedbin-web              | *  Environment: production
feedbin-web              | *          PID: 1
feedbin-web              | * Listening on http://0.0.0.0:3000
feedbin-web              | Use Ctrl-C to stop
feedbin-web              | - Gracefully stopping, waiting for requests to finish
feedbin-web              | Exiting
feedbin-web              | => Booting Puma
feedbin-web              | => Rails 6.1.4 application starting in production 
feedbin-web              | => Run `bin/rails server --help` for more startup options
feedbin-web              | I, [2021-07-14T16:36:42.476081 #1]  INFO -- honeybadger: ** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=4.8.0 framework=rails level=1 pid=1
feedbin-web              | Puma starting in single mode...
feedbin-web              | * Puma version: 5.3.2 (ruby 2.7.3-p183) ("Sweetnighter")
feedbin-web              | *  Min threads: 5
feedbin-web              | *  Max threads: 5
feedbin-web              | *  Environment: production
feedbin-web              | *          PID: 1
feedbin-web              | * Listening on http://0.0.0.0:3000
feedbin-web              | Use Ctrl-C to stop
feedbin-web              | - Gracefully stopping, waiting for requests to finish
feedbin-web              | Exiting
feedbin-web              | => Booting Puma
feedbin-web              | => Rails 6.1.4 application starting in production 
feedbin-web              | => Run `bin/rails server --help` for more startup options
feedbin-web              | I, [2021-07-14T16:46:09.660104 #1]  INFO -- honeybadger: ** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=4.8.0 framework=rails level=1 pid=1
feedbin-web              | Puma starting in single mode...
feedbin-web              | * Puma version: 5.3.2 (ruby 2.7.3-p183) ("Sweetnighter")
feedbin-web              | *  Min threads: 5
feedbin-web              | *  Max threads: 5
feedbin-web              | *  Environment: production
feedbin-web              | *          PID: 1
feedbin-web              | * Listening on http://0.0.0.0:3000
feedbin-web              | Use Ctrl-C to stop
➜  feedbin git:(feedbin) ✗ 

As I don't have an SMTP server or a Twitter account, I left those sections of the .env empty initially but then tried filling them with dummy values with no change I could tell. Here's the .env:

# Feedbin
RACK_ENV=production
RAILS_ENV=production
PORT=3000
SECRET_KEY_BASE=asdf
DEFAULT_URL_OPTIONS_HOST=feedbin.randombits.host
PUSH_URL=https://feedbin.randombits.host
FEEDBIN_URL=https://feedbin.randombits.host
FEEDBIN_HOST=feedbin.randombits.host
FORCE_SSL=false
FEEDBIN_API_HOST=api.feedbin.randombits.host

# Databases
ELASTICSEARCH_URL=http://feedbin-elasticsearch:9200
MEMCACHED_HOSTS=feedbin-memcached:11211
REDIS_URL=redis://feedbin-redis:6379

POSTGRES_USER=asdf
POSTGRES_PASSWORD=asdf

# Minio
MINIO_ACCESS_KEY=asdf
MINIO_SECRET_KEY=asdf
MINIO_BUCKET=feedbin
MINIO_HOST=minio.feedbin.randombits.host

# Extract service (needs to run behind HTTPS:443)
EXTRACT_HOST=extract.feedbin.randombits.host
EXTRACT_USER=asdf
EXTRACT_SECRET=asdf

# Camo
CAMO_HOST=camo.feedbin.randombits.host
CAMO_KEY=asdf

# SMTP
SMTP_ADDRESS=mail.example.com
SMTP_USERNAME=a
SMTP_PASSWORD=a
SMTP_DOMAIN=example.com
FROM_ADDRESS=b@example.com

# Twitter
TWITTER_KEY=1234
TWITTER_SECRET=5678

and finally my docker-compose.yaml:

x-common-variables: &feedbin-environment
- PORT
- RACK_ENV
- RAILS_ENV
- SECRET_KEY_BASE
- DEFAULT_URL_OPTIONS_HOST
- PUSH_URL
- FEEDBIN_URL
- FEEDBIN_HOST=$FEEDBIN_HOST,api.feedbin.com
- FORCE_SSL
- ELASTICSEARCH_URL
- MEMCACHED_HOSTS
- REDIS_URL
- DATABASE_URL=postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@feedbin-postgres/feedbin_production
- EXTRACT_HOST
- EXTRACT_USER
- EXTRACT_SECRET
- CAMO_HOST=https://$CAMO_HOST
- CAMO_KEY
- SMTP_ADDRESS
- SMTP_USERNAME
- SMTP_PASSWORD
- SMTP_DOMAIN
- FROM_ADDRESS
- AWS_ACCESS_KEY_ID=$MINIO_ACCESS_KEY
- AWS_SECRET_ACCESS_KEY=$MINIO_SECRET_KEY
- AWS_S3_BUCKET=$MINIO_BUCKET
- AWS_S3_BUCKET_FAVICONS=$MINIO_BUCKET
- AWS_S3_ENDPOINT=https://$MINIO_HOST
- AWS_S3_PATH_STYLE
- ENTRY_IMAGE_HOST=$MINIO_HOST
- TWITTER_KEY
- TWITTER_SECRET

version: '3.4'

networks:
  live_network:
    external: true
  internal_network:
    external: false

services:
  feedbin-minio:
    image: minio/minio:latest
    container_name: feedbin-minio
    networks:
      - "internal_network"
      - "live_network"
    environment:
      - MINIO_ACCESS_KEY
      - MINIO_SECRET_KEY
    volumes:
      - ./data/feedbin_minio:/data
    command: server /data
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.feedbin-minio-websecure.rule=Host(`minio.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-minio-websecure.entrypoints=websecure"
      - "traefik.http.routers.feedbin-minio-websecure.tls=true"
      - "traefik.http.routers.feedbin-minio-websecure.tls.certresolver=le"
      - "traefik.http.routers.feedbin-minio-web.rule=Host(`minio.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-minio-web.entrypoints=web"
      - "traefik.http.routers.feedbin-minio-web.middlewares=feedbin-minio-http-redirect"

      - "traefik.http.middlewares.feedbin-minio-http-redirect.redirectscheme.scheme=https"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  feedbin-minio-create:
    image: minio/mc:latest
    container_name: feedbin-minio-create
    networks:
      - "internal_network"
      - "live_network"
    depends_on:
      - feedbin-minio
    entrypoint: >
      /bin/sh -c "
      /usr/bin/mc config host add minio http://feedbin-minio:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY;
      /usr/bin/mc mb minio/$MINIO_BUCKET;
      /usr/bin/mc policy set download minio/$MINIO_BUCKET;
      exit 0;
      "

  feedbin-web:
    build:
      context: ./feedbin-web
      args:
        FEEDBIN_URL: $FEEDBIN_URL
    container_name: feedbin-web
    networks:
      - "internal_network"
      - "live_network"
    environment: *feedbin-environment
    depends_on:
      - feedbin-minio
      - feedbin-elasticsearch
      - feedbin-memcached
      - feedbin-redis
      - feedbin-postgres
    command: bundle exec rails s --port $PORT --binding 0.0.0.0
    expose:
      - "$PORT"
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.feedbin-web-websecure.rule=Host(`feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-web-websecure.entrypoints=websecure"
      - "traefik.http.routers.feedbin-web-websecure.tls=true"
      - "traefik.http.routers.feedbin-web-websecure.tls.certresolver=le"
      - "traefik.http.routers.feedbin-web-web.rule=Host(`feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-web-web.entrypoints=web"
      - "traefik.http.routers.feedbin-web-web.middlewares=feedbin-web-http-redirect"
      - "traefik.http.middlewares.feedbin-web-http-redirect.redirectscheme.scheme=https"

      - "traefik.http.routers.feedbin-api-websecure.rule=Host(`api.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-api-websecure.entrypoints=websecure"
      - "traefik.http.routers.feedbin-api-websecure.tls=true"
      - "traefik.http.routers.feedbin-api-websecure.tls.certresolver=le"
      - "traefik.http.routers.feedbin-api-web.rule=Host(`api.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-api-web.entrypoints=web"
      - "traefik.http.routers.feedbin-api-web.middlewares=feedbin-api-http-redirect"
      - "traefik.http.middlewares.feedbin-api-http-redirect.redirectscheme.scheme=https"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:$PORT"]
      interval: 30s
      timeout: 20s
      retries: 3

  feedbin-workers:
    build: ./feedbin-web
    container_name: feedbin-workers
    networks:
      - "internal_network"
    environment: *feedbin-environment
    command: foreman start
    restart: unless-stopped

  feedbin-elasticsearch:
    image: elasticsearch:2.4
    container_name: feedbin-elasticsearch
    networks:
      - "internal_network"
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.type=single-node
    volumes:
      - ./data/feedbin_elasticsearch:/usr/share/elasticsearch/data
    ulimits:
      memlock:
        soft: -1
        hard: -1
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9200"]
      interval: 30s
      timeout: 20s
      retries: 3

  feedbin-refresher:
    build: ./feedbin-refresher
    environment:
      - REDIS_URL
      - TWITTER_KEY
      - TWITTER_SECRET
    container_name: feedbin-refresher
    networks:
      - "internal_network"
    restart: unless-stopped

  feedbin-image:
    build: ./feedbin-image
    environment:
      - AWS_ACCESS_KEY_ID=$MINIO_ACCESS_KEY
      - AWS_SECRET_ACCESS_KEY=$MINIO_SECRET_KEY
      - AWS_S3_BUCKET=$MINIO_BUCKET
      - AWS_S3_ENDPOINT=https://$MINIO_HOST
      - AWS_S3_PATH_STYLE
      - REDIS_URL
    container_name: feedbin-image
    networks:
      - "internal_network"
    restart: unless-stopped

  feedbin-extract:
    build:
      context: ./feedbin-extract
      args:
        EXTRACT_USER: $EXTRACT_USER
        EXTRACT_SECRET: $EXTRACT_SECRET
    container_name: feedbin-extract
    networks:
      - "internal_network"
      - "live_network"
    restart: unless-stopped
    expose:
      - "$PORT"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.feedbin-extract-websecure.rule=Host(`extract.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-extract-websecure.entrypoints=websecure"
      - "traefik.http.routers.feedbin-extract-websecure.tls=true"
      - "traefik.http.routers.feedbin-extract-websecure.tls.certresolver=le"
      - "traefik.http.routers.feedbin-extract-web.rule=Host(`extract.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-extract-web.entrypoints=web"
      - "traefik.http.routers.feedbin-extract-web.middlewares=feedbin-extract-http-redirect"
      - "traefik.http.middlewares.feedbin-extract-http-redirect.redirectscheme.scheme=https"

  feedbin-camo:
    image: increments/camo
    container_name: feedbin-camo
    networks:
      - "internal_network"
      - "live_network"
    environment:
      - PORT=8081
      - CAMO_KEY
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.feedbin-camo-websecure.rule=Host(`camo.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-camo-websecure.entrypoints=websecure"
      - "traefik.http.routers.feedbin-camo-websecure.tls=true"
      - "traefik.http.routers.feedbin-camo-websecure.tls.certresolver=le"
      - "traefik.http.routers.feedbin-camo-web.rule=Host(`camo.feedbin.randombits.host`)"
      - "traefik.http.routers.feedbin-camo-web.entrypoints=web"
      - "traefik.http.routers.feedbin-camo-web.middlewares=feedbin-camo-http-redirect"
      - "traefik.http.middlewares.feedbin-camo-http-redirect.redirectscheme.scheme=https"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  feedbin-minio-create:
    image: minio/mc:latest
    container_name: feedbin-minio-create
    networks:
      - "internal_network"
      - "live_network"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8081"]
      interval: 30s
      timeout: 20s
      retries: 3

  feedbin-memcached:
    image: memcached:1.6-alpine
    container_name: feedbin-memcached
    networks:
      - "internal_network"
    restart: unless-stopped

  feedbin-redis:
    image: redis:6-alpine
    container_name: feedbin-redis
    networks:
      - "internal_network"
    volumes:
      - ./data/feedbin_redis:/data
    command: "redis-server --appendonly yes"
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 30s
      timeout: 20s
      retries: 3

  feedbin-postgres:
    image: postgres:13-alpine
    container_name: feedbin-postgres
    networks:
      - "internal_network"
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
    volumes:
      - ./data/feedbin_db:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $POSTGRES_USER"]
      interval: 30s
      timeout: 20s
      retries: 3
karlprieb commented 2 years ago

Sorry for the late reply, did you find the solution? What I can see is that my camo service is healthy, but web is always in starting mode.

conor-f commented 2 years ago

Sorry, I didn't find any solution! I just kind of left it and forgot after a few days trying to debug.

Is this presenting as an issue again? If the image has been updated since I may try again at some point soon :)

karlprieb commented 2 years ago

I'm trying to debug as I want to have better health checks. If I find any solution I can create a PR :) Also I want to create a PR to update images to Alpine 3.14 and change how we build feedbin-web image (today we build it twice).