bpatrik / pigallery2

A fast directory-first photo gallery website, with rich UI, optimized for running on low resource servers (especially on raspberry pi)
http://bpatrik.github.io/pigallery2/
MIT License
1.76k stars 202 forks source link

PiGallery2 stopped working - health issue - docker update ? #894

Open niawag opened 5 months ago

niawag commented 5 months ago

Hi, I'm using PiGallery2 with docker (latest-alpine) on a x86_64 plateform with Ubuntu 22.04. I updated my docker version to version 26.1.0, build 9714adc (latest deb available) and compose to v2.26.1 and the update seems to have broken PiGallery2. Here is my compose section:

pigallery2:
    image: bpatrik/pigallery2:latest-alpine
    container_name: pigallery2
    environment:
      - NODE_ENV=production 
      - TZ=Europe/Paris
      - PUID=1026
     - PGID=100
    networks:
      - t2_proxy
    security_opt:
      - no-new-privileges:true
    restart: always
    volumes:
      - "./pigallery2/config:/app/data/config"
      - "./pigallery2/db-data:/app/data/db"
      - "/mnt/photo:/app/data/images:ro"
      - "./pigallery2/tmp:/app/data/tmp"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.pigall-rtr.entrypoints=https"
      - "traefik.http.routers.pigall-rtr.rule=Host(`pigall.mydomain.wtf`)"
      - "traefik.http.routers.pigall-rtr.tls=true"
      - "traefik.http.routers.pigall-rtr.service=pigall-svc"
      - "traefik.http.services.pigall-svc.loadbalancer.server.port=80"
      - "traefik.http.routers.pigall-rtr.middlewares=localip"

The debug logs seems OK

I tried with edge-alpine and lastest images, same issue. Is there someone else affected by this bug ? Is there anything I can do to help fixing that bug ?

niawag commented 5 months ago

After some testing, it seems the latest docker version is responsible. I downgraded the following packages to these versions:

docker-ce=5:25.0.5-1~ubuntu.22.04~jammy
docker-ce-cli=5:25.0.5-1~ubuntu.22.04~jammy
docker-compose-plugin=2.25.0-1~ubuntu.22.04~jammy

(using sudo apt install docker-ce=5:25.0.5-1~ubuntu.22.04~jammy and so on) And PiGallery is up and running. (tested with docker 26.0.2-1, not working either)

I have a lot of differents containers running on that server, all the others were running fine on the latest docker version so it must be something specific to PiGallery

bpatrik commented 5 months ago

yeah those logs does not tell much. I have't run into this issue yet, so I cant really comment.

i see that a worker thread is trying to come up. You can disable threading in the config. Its deprecated. Maybe that makes a difference.

niawag commented 5 months ago

I think it's related to Traefik + docker 26 + healthcheck adress. PiGallery is unhealthy because of changes made to docker 26 (or another reason) --> traefik does not create the router

I had a similar problem with another container (Filebrowser) and I solved it using that thread: https://github.com/filebrowser/filebrowser/issues/3119#issuecomment-2056009188

I've disabled the healthcheck in my compose file and all is working with docker 26.1:

  healthcheck:
    disable: true
niawag commented 4 months ago

Can I create a PR to fix this issue ? The problem seems related to localhost endpoint, I've fixed it by adding this in my compose.yml file:

    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://127.0.0.1 || exit 1
      start_interval: 5s
      interval: 60s
      retries: 3
      start_period: 20s
      timeout: 10s

I can deploy this fix by changing localhost by 127.0.0.1 in the HEALTHCHECK section here: https://github.com/bpatrik/pigallery2/blob/9c6a7c97e3f86afc4bd280b5c6d824fa0aa6b0ad/docker/alpine/Dockerfile

Here are the results from inside PiGallery2 container: With localhost:

/app # wget --tries=1 --no-check-certificate --spider http://localhost:80
Connecting to localhost:80 ([::1]:80)
wget: can't connect to remote host: Connection refused

With 127.0.0.1:

/app # wget --tries=1 --no-check-certificate --spider http://127.0.0.1:80
Connecting to 127.0.0.1:80 (127.0.0.1:80)
remote file exists

The result of wget suggest it's a problem with IP v6 resolution instead of IP v4 (Connecting to localhost:80 ([::1]:80)) but busybox wget doesn't support --inet4-only option to force IP v4 resolution

bpatrik commented 3 months ago

I would appreciate if you can send a PR with the fix.

Please note there are 4-5 Dockerfiles within the docker folder, please update all of them

niawag commented 3 months ago

Hi, I've made a PR with the mentionned changes (https://github.com/bpatrik/pigallery2/pull/920), it should get rid of this issue. Thanks for letting me be a part of this !