linuxserver / docker-grocy

A container for grocy - the ERP application for your kitchen https://grocy.info
GNU General Public License v3.0
321 stars 44 forks source link

[BUG] No data shown in UI after docker pull new images #79

Closed Aephir closed 7 months ago

Aephir commented 7 months ago

Is there an existing issue for this?

Current Behavior

Not sure if related to #9 or #50 but there are no answers for those.

I have grocy in my docker-compose.yaml.

relevant docker-compose.yaml ``` version: '3.7' services: grocy: image: lscr.io/linuxserver/grocy:latest container_name: grocy environment: - PUID=1000 - PGID=1000 - TZ=Europe/Copenhagen volumes: - /mnt/data/docker/grocy:/var/www/data ports: - "10.0.30.21:9283:80" restart: unless-stopped ```

After doing:

docker kill $(docker ps -q)
docker-compose build
docker-compose pull
docker-compose up -d

Everything is gone after logging in. Password has reset to default admin/admin, and no products, product_groups, location, etc. were present.

Output of docker logs grocy ``` $ docker logs grocy [migrations] started [migrations] 01-nginx-site-confs-default: executing... [migrations] 01-nginx-site-confs-default: succeeded [migrations] 02-default-location: executing... [migrations] 02-default-location: succeeded [migrations] done ─────────────────────────────────────── ██╗ ███████╗██╗ ██████╗ ██║ ██╔════╝██║██╔═══██╗ ██║ ███████╗██║██║ ██║ ██║ ╚════██║██║██║ ██║ ███████╗███████║██║╚██████╔╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ Brought to you by linuxserver.io ─────────────────────────────────────── To support LSIO projects visit: https://www.linuxserver.io/donate/ ─────────────────────────────────────── GID/UID ─────────────────────────────────────── User UID: 1000 User GID: 1000 ─────────────────────────────────────── Setting resolver to 127.0.0.11 Setting worker_processes to 16 generating self-signed keys in /config/keys, you can replace these with your own keys if required .........+...+..+....+++++++++++++++++++++++++++++++++++++++*.+.....+...+.+.....+......+.+........+..........+...........+.+.........+.....+...+...+...+.+........+.+.....+.+...+...........+++++++++++++++++++++++++++++++++++++++*.....................+...+...++++++ ..+++++++++++++++++++++++++++++++++++++++*.+.......+++++++++++++++++++++++++++++++++++++++*.+...+..........+...........+......+...+...+...............+...+.++++++ ----- [custom-init] No custom files found, skipping... [ls.io-init] done. [migrations] started [migrations] 01-nginx-site-confs-default: skipped [migrations] 02-default-location: skipped [migrations] done usermod: no changes ─────────────────────────────────────── ██╗ ███████╗██╗ ██████╗ ██║ ██╔════╝██║██╔═══██╗ ██║ ███████╗██║██║ ██║ ██║ ╚════██║██║██║ ██║ ███████╗███████║██║╚██████╔╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ Brought to you by linuxserver.io ─────────────────────────────────────── To support LSIO projects visit: https://www.linuxserver.io/donate/ ─────────────────────────────────────── GID/UID ─────────────────────────────────────── User UID: 1000 User GID: 1000 ─────────────────────────────────────── using keys found in /config/keys [custom-init] No custom files found, skipping... [ls.io-init] done. ```

I did have the web UI open (in a background window) while I did the docker pull, and I saw this page when I navigated back:

Screenshot 2023-12-12 at 17 36 56
I've pasted the logs and stack trace from that page here: ### A server error occured while processing your request Error source ``` /app/www/packages/morris/lessql/src/LessQL/Database.php:110 ``` Error message ``` SQLSTATE[HY000]: General error: 1 no such table: sessions ``` Stack trace ``` #0 /app/www/packages/morris/lessql/src/LessQL/Database.php(110): PDO->prepare() #1 /app/www/packages/morris/lessql/src/LessQL/Database.php(493): LessQL\Database->prepare() #2 /app/www/packages/morris/lessql/src/LessQL/Result.php(143): LessQL\Database->select() #3 /app/www/packages/morris/lessql/src/LessQL/Result.php(322): LessQL\Result->execute() #4 /app/www/services/SessionService.php(54): LessQL\Result->fetch() #5 /app/www/middleware/SessionAuthMiddleware.php(21): Grocy\Services\SessionService->IsValidSession() #6 /app/www/middleware/DefaultAuthMiddleware.php(24): Grocy\Middleware\SessionAuthMiddleware->authenticate() #7 /app/www/middleware/AuthMiddleware.php(53): Grocy\Middleware\DefaultAuthMiddleware->authenticate() #8 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\AuthMiddleware->__invoke() #9 /app/www/packages/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #10 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\RoutingMiddleware->process() #11 /app/www/packages/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #12 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process() #13 /app/www/middleware/CorsMiddleware.php(27): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #14 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\CorsMiddleware->__invoke() #15 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #16 /app/www/packages/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle() #17 /app/www/packages/slim/slim/Slim/App.php(183): Slim\App->handle() #18 /app/www/app.php(112): Slim\App->run() #19 /app/www/public/index.php(45): require_once('...') #20 {main} ``` Easy error info copy & paste (for reporting) ``` Error source: ``` /app/www/packages/morris/lessql/src/LessQL/Database.php:110 ``` Error message: ``` SQLSTATE[HY000]: General error: 1 no such table: sessions ``` Stack trace: ``` #0 /app/www/packages/morris/lessql/src/LessQL/Database.php(110): PDO->prepare() #1 /app/www/packages/morris/lessql/src/LessQL/Database.php(493): LessQL\Database->prepare() #2 /app/www/packages/morris/lessql/src/LessQL/Result.php(143): LessQL\Database->select() #3 /app/www/packages/morris/lessql/src/LessQL/Result.php(322): LessQL\Result->execute() #4 /app/www/services/SessionService.php(54): LessQL\Result->fetch() #5 /app/www/middleware/SessionAuthMiddleware.php(21): Grocy\Services\SessionService->IsValidSession() #6 /app/www/middleware/DefaultAuthMiddleware.php(24): Grocy\Middleware\SessionAuthMiddleware->authenticate() #7 /app/www/middleware/AuthMiddleware.php(53): Grocy\Middleware\DefaultAuthMiddleware->authenticate() #8 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\AuthMiddleware->__invoke() #9 /app/www/packages/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #10 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\RoutingMiddleware->process() #11 /app/www/packages/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #12 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process() #13 /app/www/middleware/CorsMiddleware.php(27): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #14 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(269): Grocy\Middleware\CorsMiddleware->__invoke() #15 /app/www/packages/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #16 /app/www/packages/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle() #17 /app/www/packages/slim/slim/Slim/App.php(183): Slim\App->handle() #18 /app/www/app.php(112): Slim\App->run() #19 /app/www/public/index.php(45): require_once('...') #20 {main} ``` System info: ``` { "grocy_version": { "Version": "4.0.3", "ReleaseDate": "2023-09-02" }, "php_version": "8.2.13", "sqlite_version": "3.41.2", "os": "Linux 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64", "client": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko\/20100101 Firefox\/120.0" } ``` ```

Expected Behavior

All data should remain when I update the docker container without changing anything with the persistent_data.

Steps To Reproduce

  1. In Ubuntu Server LTS (22.04) with docker (Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1) and docker-compose (docker-compose version 1.28.5, build c4eb3a1f) with docker-compose.yaml as shown above, set up linuxserver/grocy and add items.
  2. Update container as described above.

Environment

- OS: Ubuntu Server 22.04
- How docker service was installed: Can't remember, I think it was snap, but this is the version `Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1`

CPU architecture

x86-64

Docker creation

See above.

Container logs

See above.
github-actions[bot] commented 7 months ago

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

aptalca commented 7 months ago

You're mounting an incorrect folder. Please follow the readme

Aephir commented 7 months ago

I started with:

  grocy:
    image: lscr.io/linuxserver/grocy:latest
    container_name: grocy
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Copenhagen
    volumes:
      - /mnt/data/docker/grocy:/config
    ports:
      - "10.0.30.21:9283:80"
    restart: unless-stopped

I had it working a loooong time ago, but hadn't used it for many months (years?) until I tried again recently, and it no longer worked; I just got a page showing:

Unable to run Grocy: config.php in data directory (/app/www/public/../data) not found. Have you copied config-dist.php to the data directory and renamed it to config.php?

Searching for a fix, I found someone saying that swapping :/config to :/var/www/data worked for them. Different docker image, I think, but I tried, and it worked where nothing else did.

EDIT: Also found suggestion of :/var/www/data` here

Since then, it has worked until today when I updated the container. Changing back to /mnt/data/docker/grocy:/config gives the same result that made me change to /mnt/data/docker/grocy:/var/www/data in the first place, the web UI doesn't load (The page isn’t redirecting properly) despite no errors in docker logs if keeping the persistent data (initially created with /mnt/data/docker/grocy:/config).

If deleting persistent data (re-creating everything from scratch like this), I get the `Unable to run Grocy` instead. with ``` grocy: image: lscr.io/linuxserver/grocy:latest container_name: grocy environment: - PUID=1000 - PGID=1000 - TZ=Europe/Copenhagen volumes: - /mnt/data/docker/grocy:/config ports: - "10.0.30.21:9283:80" restart: unless-stopped ``` in docker-compose.yaml, doing: ``` docker kill grocy sudo rm -rf /mnt/data/docker/grocy docker-compose up -d ``` Gives the ``` The page isn’t redirecting properly`) despite no errors in docker logs if keeping the persistent data (initially created with `/mnt/data/docker/grocy:/config ```

So it seems like I should worry about why a new instance with docker-compose as in this post doesn't get me to the login page instead?

Any idea why that is?

aptalca commented 7 months ago

You can't just switch mount points like that and expect it not to break. That suggestion you linked is not even for this image. Your persistent folder on host is likely broken beyond repair.

You need to either start with a fresh config folder and start over, or restore from a working backup (likely from before you switched the mount point in the first place.

Aephir commented 7 months ago

It's not so much that I didn't expect anything to break when changing mount points, it's more that it already was broken using /config (after not accessing it for a while), before making changes to the documented setup, so I got a bit... desperate? Adventurous? Somewhere in between.

But sure, I'll restart (I have scripts to re-add all products). And avoid leaving it running for months/years between using it going forward.

aptalca commented 7 months ago

I get that. If you had come to us when it first broke during an upgrade, we could have helped. But after changing mounts, too much is changed and we can't possibly reproduce your setup to properly troubleshoot.

If it breaks again, feel free to drop by our Discord, which is great for quick chats and troubleshooting.

Good luck!