linuxserver / docker-snipe-it

Alpine/Nginx container for the Asset Management software Snipe-IT
GNU General Public License v3.0
123 stars 26 forks source link

[BUG] Snipe-IT can't use Redis. #58

Closed dylanbegin closed 1 year ago

dylanbegin commented 1 year ago

Is there an existing issue for this?

Current Behavior

Configured env file with Redis settings.

REDIS_HOST=redis-name
REDIS_PORT=port-number
REDIS_PASSWORD=my-password
CACHE_DRIVER=redis

Snipe-IT larvel log displays the following error: Please make sure the PHP Redis extension is installed and enabled. in /app/www/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php

Expected Behavior

Snipe should be able to use Redis with V6 or newer, but the Dockerfile is missing "php81-redis" package.

Steps To Reproduce

Environment

- OS: Fedora 37 and latest Docker version.
- How docker service was installed: docker stack deploy -c /path/to/docker-compose.yml swarm-dev

CPU architecture

x86-64

Docker creation

######### SNIPE-IT #########
  snipe-cache:
    image: redis:alpine
    networks:
      - net
    user: uid:gid
    volumes:
      - /path/to/snipe:/data
      - /etc/localtime:/etc/localtime:ro
    environment:
      TZ: "my/tz"
    command: redis-server --save 60 1 --loglevel warning --requirepass my-pass
    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 20s
      resources:
        limits:
          memory: 1gb
  snipe:
    image: linuxserver/snipe-it:latest
    networks:
      - net
    volumes:
      - /path/to/config:/config
      - /etc/localtime:/etc/localtime:ro
    environment:
      PUID: uid
      PGID: gid
      TZ: "my/tz"
    env_file:
      - /path/to/snipe-env
    depends_on:
      - snipe-cache
    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 20s
      resources:
        limits:
          memory: 1gb

Container logs

swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | [migrations] started
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | [migrations] 01-nginx-site-confs-default: skipped
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | [migrations] 02-default-location: skipped
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | [migrations] done
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ───────────────────────────────────────
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       ██╗     ███████╗██╗ ██████╗
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       ██║     ██╔════╝██║██╔═══██╗
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       ██║     ███████╗██║██║   ██║
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       ██║     ╚════██║██║██║   ██║
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       ███████╗███████║██║╚██████╔╝
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       ╚══════╝╚══════╝╚═╝ ╚═════╝
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |    Brought to you by linuxserver.io
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ───────────────────────────────────────
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | To support the app dev(s) visit:
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | Snipe-IT: https://snipeitapp.com/donate
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | To support LSIO projects visit:
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | https://www.linuxserver.io/donate/
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ───────────────────────────────────────
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | GID/UID
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ───────────────────────────────────────
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | User UID:    removed
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | User GID:    removed
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ───────────────────────────────────────
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | using keys found in /config/keys
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |    Illuminate\Database\QueryException
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |   SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mariadb failed: Name does not resolve (SQL: select * from information_schema.tables where table_schema = snipe and table_name = migrations and table_type = 'BASE TABLE')
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |   at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     708▕         // If an exception occurs when attempting to run a query, we'll format the error
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     709▕         // message to include the bindings with SQL, which will make this exception a
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     710▕         // lot more helpful to the developer instead of just the database's errors.
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     711▕         catch (Exception $e) {
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |   ➜ 712▕             throw new QueryException(
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     713▕                 $query, $this->prepareBindings($bindings), $e
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     714▕             );
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     715▕         }
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |     716▕     }
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       +33 vendor frames
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |   34  /app/www/artisan:35
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    |       Illuminate\Foundation\Console\Kernel::handle()
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | **** The following active confs have different version dates than the samples that are shipped. ****
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | **** This may be due to user customization or an update to the samples. ****
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | **** You should compare the following files to the samples in the same folder and update them. ****
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | **** Use the link at the top of the file to view the changelog. ****
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | │  old date  │  new date  │ path                                                                   │
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | ├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | │            │ 2022-08-20 │ /config/nginx/site-confs/default.conf                                  │
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | │ 2021-10-24 │ 2022-08-16 │ /config/nginx/nginx.conf                                               │
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | └────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | [custom-init] No custom files found, skipping...
swarm-dev_snipe.1.63un5rjx3q9j@docker-host.my-domain.com    | [ls.io-init] done.
github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

thespad commented 1 year ago

As a quick fix you can apk add php81-pecl-redis.

I'll PR an update to the image deps and add it in.

dylanbegin commented 1 year ago

Awesome, thanks for the quick feedback! Love the product!

aptalca commented 1 year ago

You can also use this mod, which would make it persistent: https://github.com/linuxserver/docker-mods/tree/universal-package-install

dylanbegin commented 1 year ago

@aptalca thanks for this! This will be helpful for my code server container too.