-
-
Notifications
You must be signed in to change notification settings - Fork 79
Description
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:
- Change data volume in docker-compose.yml from a docker controlled one to a known folder.
- Run
docker compose up
- 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
Lines 2 to 3 in 4372664
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)
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