oae / kaizoku

Self-hosted manga downloader
https://kaizoku.app
MIT License
553 stars 33 forks source link

Fresh Docker Install, loads UI but won't load Available Sources #141

Closed alejakun closed 11 months ago

alejakun commented 11 months ago

Describe the bug

I just installed with the docker image, it seems to work fine, however it does not show anything when trying to add a New Library/Manga in the field Available sources. Checking at the logs it shows the following:

{"level":50,"time":1696973407106,"pid":308,"hostname":"d12d3bc2e27a","msg":"Failed to get available sources. err: Error: Command failed with exit code 2: mangal sources list -r\npanic: mkdir /config/.config/mangal/sources: permission denied\n\ngoroutine 1 [running]:\ngithub.com/samber/lo.must({0xefeae0, 0xc000476d80}, {0x0, 0x0, 0x0})\n\tgithub.com/samber/lo@v1.37.0/errors.go:53 +0x1f4\ngithub.com/samber/lo.Must0(...)\n\tgithub.com/samber/lo@v1.37.0/errors.go:72\ngithub.com/metafates/mangal/where.mkdir({0xc000265aa0, 0x1e})\n\tgithub.com/metafates/mangal/where/where.go:18 +0x57\ngithub.com/metafates/mangal/where.Sources()\n\tgithub.com/metafates/mangal/where/where.go:39 +0x5b\ngithub.com/metafates/mangal/provider.Customs()\n\tgithub.com/metafates/mangal/provider/provider.go:31 +0x49\ngithub.com/metafates/mangal/cmd.glob..func24.3()\n\tgithub.com/metafates/mangal/cmd/sources.go:67 +0x3b\ngithub.com/metafates/mangal/cmd.glob..func24(0x1d291e0, {0x101d881?, 0x1?, 0x1?})\n\tgithub.com/metafates/mangal/cmd/sources.go:82 +0x3ea\ngithub.com/spf13/cobra.(*Command).execute(0x1d291e0, {0xc0004a0640, 0x1, 0x1})\n\tgithub.com/spf13/cobra@v1.6.1/command.go:920 +0x847\ngithub.com/spf13/cobra.(*Command).ExecuteC(0x1d2a040)\n\tgithub.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd\ngithub.com/spf13/cobra.(*Command).Execute(...)\n\tgithub.com/spf13/cobra@v1.6.1/command.go:968\ngithub.com/metafates/mangal/cmd.Execute()\n\tgithub.com/metafates/mangal/cmd/root.go:112 +0x7a\nmain.main()\n\tgithub.com/metafates/mangal/main.go:13 +0x4d\nMangadex\nManganelo\nManganato\nMangapill"}

Reproduction steps

Fresh install with the following docker compose:

  kaizoku:
    image: ghcr.io/oae/kaizoku:latest
    container_name: kaizoku
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - traefik
    ports:
      - "$KAIZOKU_PORT:3000"
    environment:
      - DATABASE_URL=postgresql://kaizoku:kaizoku@kaizoku_db:5432/kaizoku
      - KAIZOKU_PORT=3000
      - REDIS_HOST=kaizoku_redis
      - REDIS_PORT=6379
      - PUID=$PUID
      - PGID=$PGID
      - TZ=$TZ
    volumes:
      - $PWD/kaizoku/config:/config
      - $PWD/kaizoku/data:/data
      - $PWD/kaizoku/logs:/logs
    depends_on:
      kaizoku_db:
        condition: service_healthy

  kaizoku_redis:
    image: redis:7-alpine
    container_name: kaizoku_redis
    user: "$PUID:$PGID"
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - traefik
    volumes:
      - $PWD/kaizoku/redis:/data
  kaizoku_db:
    image: postgres:15-alpine
    container_name: kaizoku_db
    user: "$PUID:$PGID"
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - traefik
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U kaizoku']
      interval: 5s
      timeout: 5s
      retries: 5
    environment:
      - POSTGRES_USER=kaizoku
      - POSTGRES_DB=kaizoku
      - POSTGRES_PASSWORD=kaizoku
    volumes:
      - $PWD/kaizoku/postgres:/var/lib/postgresql/data

Expected behavior

Should load something for Available sources.

Additional context

No response

notHiks commented 11 months ago

you have a permisison error. the docker u8ser cazn't write to the filesystem

mkdir /config/.config/mangal/sources: permission denied\n\ngoroutine 1

alejakun commented 11 months ago

Hi, thanks for the reply. I totally agree, however I see no reason why this is happening, since the user was able to create the whole filesystem structure starting from config (ie. /config/.config/mangal/sources), with what is in fact the user I specified in the compose environment. Just to be sure I deleted the directories and started again (easy since docker), but I still have the same behavior:

The docker user creates the directories structure with correct user/group information but sends the same error.

One thing I noticed which strikes me as odd (not necessarily wrong, just odd), is the permissions for file: /config/.config/mangal/mangal.toml which was created (again fresh run), with user ownership as: root:root

Any thoughts would be greatly appreciated.

notHiks commented 11 months ago

root should not own that file. for my install all files in /config are owned by the same user.

alejakun commented 11 months ago

Are you using the Docker version?

notHiks commented 11 months ago

yes i'm running it on docker. i'm also pointing the files to a NAS so all ownership is tied to the same user id's.

alejakun commented 11 months ago

It should be the same for me, or at least it’s what I’m expecting with the environment variables set to ($PUID and $PGID have correct values):

      - PUID=$PUID
      - PGID=$PGID
alejakun commented 11 months ago

@notHiks , would you mind sharing your docker-compose or docker command just to compare?

alejakun commented 11 months ago

At the end it seems to have problemas when you set the user:group information (at least in my case). In the end I just commented the lines and restarted docker and it worked, however I would not consider this as closed since the docker compose explicitly stated the options and I would not work like that (which would be better since I'm not really a fan of letting a container run as root).

Best regards.

notHiks commented 11 months ago

a run it behind a vpn and the storage is on a NAS owned by user 1000

services:
  app:
    container_name: kaizoku
    network_mode: "container:gluetun"
    image: ghcr.io/oae/kaizoku:latest
    environment:
      - DATABASE_URL=postgresql://kaizoku:kaizoku@0.0.0.0:5432/kaizoku
      - KAIZOKU_PORT=3000
      - REDIS_HOST=0.0.0.0
      - REDIS_PORT=6379
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    volumes:
      - /home/appdata/storage/Manga:/data
      - /home/appdata/storage/.kaizoku/config:/config
      - /home/appdata/storage/.kaizoku/logs:/logs
    depends_on:
      db:
        condition: service_healthy
    security_opt:
      - no-new-privileges:true
   # ports:
   #   - '3000:3000'

  redis:
    container_name: kaizoku-redis
    image: redis:7-alpine
    network_mode: "container:gluetun"
    restart: unless-stopped
    volumes:
      - redis:/data
    security_opt:
      - no-new-privileges:true

  db:
    container_name: kaizoku-db
    image: postgres:alpine
    network_mode: "container:gluetun"
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U kaizoku']
      interval: 5s
      timeout: 5s
      retries: 5
    environment:
      - POSTGRES_USER=kaizoku
      - POSTGRES_DB=kaizoku
      - POSTGRES_PASSWORD=kaizoku
    volumes:
      - db:/var/lib/postgresql/dat
alejakun commented 11 months ago

I swear I double checked my permissions, but with all the containers maybe they were al messed up, it's working now with my user, sorry for the time.

Best Regards.