Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLiteError: no such table: user #133

Open
tehniemer opened this issue Sep 28, 2024 · 12 comments · Fixed by #150
Open

SQLiteError: no such table: user #133

tehniemer opened this issue Sep 28, 2024 · 12 comments · Fixed by #150
Assignees
Labels
bug Something isn't working

Comments

@tehniemer
Copy link

tehniemer commented Sep 28, 2024

Followed the docker install instructions and was presented with the following error when trying to access the service.

SQLiteError: no such table: user
�
1
      at prepare (bun:sqlite:280:10)
      at prepareQuery (/app/node_modules/drizzle-orm/bun-sqlite/session.js:20:30)
      at _prepare (/app/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:572:73)
      at all (/app/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:588:17)
      at execute (/app/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:596:19)
      at then (/app/node_modules/drizzle-orm/query-promise.js:21:17)
15 |   logger;
16 |   exec(query) {
17 |     this.client.exec(query);
18 |   }
19 |   prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
20 |     const stmt = this.client.prepare(query.sql);

Here's my compose snippet

services:
  grimoire:
    image: goniszewski/grimoire:develop
    build:
      context: .
      dockerfile: Dockerfile
    container_name: grimoire
    restart: unless-stopped
    networks:
      - traefik
    ports:
      - $GRIMOIRE_PORT:5173
    security_opt:
      - no-new-privileges=true
    logging:
      options:
        max-size: 2m
        max-file: "3"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /opt/docker/grimoire:/app/data/
    environment:
      - PORT=5173
      - PUBLIC_HTTPS_ONLY=false
      - PUBLIC_SIGNUP_DISABLED=false
    labels:
      - homepage.group=Containers
      - homepage.name=Grimoire
      - homepage.icon=grimoire
      - homepage.description=Bookmark Management
      - homepage.href=https://grimoire.$DOMAINNAME
      - homepage.siteMonitor=http://$HOST:$GRIMOIRE_PORT
      - traefik.enable=true
      - traefik.http.routers.grimoire-rtr.entrypoints=https
      - traefik.http.routers.grimoire-rtr.rule=Host(`grimoire.$DOMAINNAME`)
      - traefik.http.routers.grimoire-rtr.middlewares=chain-no-auth@file # No Authentication
      - traefik.http.routers.grimoire-rtr.service=grimoire-svc
      - traefik.http.services.grimoire-svc.loadbalancer.server.port=5173
@goniszewski
Copy link
Owner

Hello @tehniemer!

Could you try to set up the app again using the latest tag for the Docker image (develop may be missing some latest hotfixes)?

Also, make sure to remove existing Docker volume used by Grimoire and allow it to create a new one.

@tehniemer
Copy link
Author

tehniemer commented Sep 28, 2024

Sure thing, after removing the existing mountpoint and changing to the latest tag I get the following errors

$ bun run ./migrate
1 | import { Database } from 'bun:sqlite';
2 | import { drizzle } from 'drizzle-orm/bun-sqlite';
3 | import { migrate } from 'drizzle-orm/bun-sqlite/migrator';
4 | 
5 | const sqlite = new Database('data/db.sqlite');
                   ^
SQLiteError: unable to open database file
 errno: 14
  code: "SQLITE_CANTOPEN"
      at new Database (bun:sqlite:178:14)
      at /app/migrate.js:5:16
Bun v1.1.29 (Linux x64 baseline)
error: script "run-migrations" exited with code 1
$ bun run ./migrate
1 | import { Database } from 'bun:sqlite';
2 | import { drizzle } from 'drizzle-orm/bun-sqlite';
3 | import { migrate } from 'drizzle-orm/bun-sqlite/migrator';
4 | 
5 | const sqlite = new Database('data/db.sqlite');
                   ^

Maybe a permissions issue with the bind mount? What UID and GID does the container run?

@goniszewski
Copy link
Owner

I've tried to reproduce your issue, but unsuccessfully. For the permissions used, please check this line in the Dockerfile: https://github.com/goniszewski/grimoire/blob/main/Dockerfile#L11

@victornavorskie
Copy link

same issue here

@DavidDotCheck
Copy link

same, doesn't work for me either

@DavidDotCheck
Copy link

Something fun that I noticed is that running adduser --disabled-password --gecos '' grimoire and mkdir -p /app/data && chown -R grimoire:grimoire /app/data && chmod 755 /app/data inside the container, then switching the tag to latest fixes both issues:

$ sudo rm -rf /etc/grimoire/data/
$ sudo nano /etc/grimoire/docker-compose.yml 
$ sudo docker-compose up -d
WARNING: The PORT variable is not set. Defaulting to a blank string.
Creating grimoire ... done
$docker exec -it 43f8aa47b259 bash
root@43f8aa47b259:/app# mkdir -p /app/data && chown -R grimoire:grimoire /app/data && chmod 755 /app/data
chown: invalid user: 'grimoire:grimoire'
root@43f8aa47b259:/app# adduser --disabled-password --gecos '' grimoire
Adding user `grimoire' ...
Adding new group `grimoire' (1001) ...
Adding new user `grimoire' (1001) with group `grimoire' ...
Creating home directory `/home/grimoire' ...
Copying files from `/etc/skel' ...
root@43f8aa47b259:/app# mkdir -p /app/data && chown -R grimoire:grimoire /app/data && chmod 755 /app/data
root@43f8aa47b259:/app# exit
exit
$ sudo docker-compose down
WARNING: The PORT variable is not set. Defaulting to a blank string.
Stopping grimoire ... 
^CERROR: Aborting.
$  docker rm -f $ID
43f8aa47b259
$ sudo nano /etc/grimoire/docker-compose.yml 
$ sudo docker-compose up -d
WARNING: The PORT variable is not set. Defaulting to a blank string.
Creating grimoire ... done

Just doing docker-compose up after running the commands doesn't fix the issue because now the user table doesn't exist.

@AnonymousX86
Copy link

I've found an interesting thing. Using a directory mount causes the error.

# This doesn't work
volumes:
  - ./data:/app/data

Removing volumes makes the app start, as well as using Docker volume.

# This works
# volumes
#   -./data:/app/data
# This works
volumes:
  grimoire_data:/app/data

@tehniemer
Copy link
Author

tehniemer commented Oct 18, 2024

That usually means it's a directory permission issue. If the container doesn't run as root or chown the directory after creation this tends to happen.

I've removed this from my stack so I'm not able to test this.

@goniszewski
Copy link
Owner

I may have introduced some unnecessary permission changes in the latest update to Dockerfile. Sorry for that, I will look into this in the next days.

@AnonymousX86
Copy link

Best would be to make use of PUID and PGID.

@Roalkege
Copy link

image

same issue with unraid.

@goniszewski goniszewski self-assigned this Nov 12, 2024
@goniszewski goniszewski added the bug Something isn't working label Nov 12, 2024
@goniszewski goniszewski linked a pull request Nov 14, 2024 that will close this issue
@goniszewski
Copy link
Owner

Possible fix for this issue is now being released under the preview tag of the Docker image: https://github.com/goniszewski/grimoire/actions/runs/11844872252

Please let me know if it's still not working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants