Skip to content

Mounted volume has permissions errors #184

@pe1uca

Description

@pe1uca

Describe the bug
Changing the volume from - grimoire_data:/app/data/ to something like - ./grimoire_data:/app/data/ (i.e. controlling what folder is mounted instead of docker creating it in some hidden location) gives several permissions errors.

To Reproduce
Steps to reproduce the behavior:

  1. Change data volume in docker-compose.yml from a docker controlled one to a known folder.
  2. Run docker compose up
  3. See several errors related to permissions

Expected behavior
Grimoire should start properly.

Additional context
Logs

grimoire             | chown: changing ownership of '/app/data': Operation not permitted
grimoire             | chmod: changing permissions of '/app/data': Operation not permitted
grimoire             | $ bun run ./migrate
grimoire             | 1 | import { Database } from 'bun:sqlite';
grimoire             | 2 | import { drizzle } from 'drizzle-orm/bun-sqlite';
grimoire             | 3 | import { migrate } from 'drizzle-orm/bun-sqlite/migrator';
grimoire             | 4 | 
grimoire             | 5 | const sqlite = new Database('data/db.sqlite');
grimoire             |                    ^
grimoire             | SQLiteError: unable to open database file
grimoire             |       errno: 14,
grimoire             |  byteOffset: -1,
grimoire             |        code: "SQLITE_CANTOPEN"
grimoire             | 
grimoire             |       at new Database (bun:sqlite:236:28)
grimoire             |       at /app/migrate.js:5:16
grimoire             | 
grimoire             | Bun v1.2.4 (Linux x64 baseline)
grimoire             | error: script "run-migrations" exited with code 1
grimoire exited with code 1

Seems this was tried to be mitigated with the entrypoint script in here

chown -R grimoire:grimoire /app/data
chmod 755 /app/data

But I think since the Dockerfile runs this already as the grimore user it can't perform this operation (haven't tested it)

grimoire/Dockerfile

Lines 91 to 96 in 4372664

RUN chmod +x /docker-entrypoint.sh
USER grimoire
EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:$PORT/api/health || exit 1
ENTRYPOINT ["/docker-entrypoint.sh"]

Seems the solution would be to specify only the bun commands to be run as the grimoire user according to this answer:
https://stackoverflow.com/a/39398511

As a workaround, seems this command in the host allows the docker container to work
chown 1001:1001 -R ./grimoire_data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions