Database should be in a different directory #23

Closed
opened 2024-12-28 03:01:12 +01:00 by harmontt · 5 comments

It would be much easier to ensure the db is saved if it were in it's own directory.
This would also allow for the db to be a volume in a k8s instance.
The proposed fix would be to set all instances of "app.db" in app.py and db.py to "db/app.db"
I have tested that this solution works in my k8s cluster.

It would be much easier to ensure the db is saved if it were in it's own directory. This would also allow for the db to be a volume in a k8s instance. The proposed fix would be to set all instances of "app.db" in app.py and db.py to "db/app.db" I have tested that this solution works in my k8s cluster.

Agreed, although I would go a step further and move all user-data into a single folder. This has multiple benefits:

  1. Allows you to add/change the underlying structure/organization without anyone having to update their setup.
  2. Prevents issues with mounting a file vs. a folder. I has to use the following in my docker compose file to mount the file, otherwise it keep trying to create a directory instead.
      - type: bind
        source: /mnt/host/apps/bricktracker/config/app.db
        target: /app/app.db

Also, it looks like the *.csv files that are downloaded in the /app directory and possibly the entirety of the /app/static directory should also be mounted to an external volume to allow the data to survive container updates.

Agreed, although I would go a step further and move all user-data into a single folder. This has multiple benefits: 1. Allows you to add/change the underlying structure/organization without anyone having to update their setup. 2. Prevents issues with mounting a file vs. a folder. I has to use the following in my docker compose file to mount the file, otherwise it keep trying to create a directory instead. ``` - type: bind source: /mnt/host/apps/bricktracker/config/app.db target: /app/app.db ``` Also, it looks like the *.csv files that are downloaded in the /app directory and possibly the entirety of the /app/static directory should also be mounted to an external volume to allow the data to survive container updates.

Indeed it should. I will probably fix this when i cleanup the code and refactor it.

Indeed it should. I will probably fix this when i cleanup the code and refactor it.
FrederikBaerentsen added the
Kind/Enhancement
Priority
Low
labels 2024-12-28 10:01:08 +01:00
FrederikBaerentsen added this to the General Improvements project 2024-12-29 16:43:41 +01:00
FrederikBaerentsen added this to the Version 1 milestone 2024-12-29 16:52:47 +01:00

I would like to +1 this since I am using a docker swarm setup with NFS mounts and there I cannot mount a file directly. If you need help testing I would volunteer with said docker swarm.

I would like to +1 this since I am using a docker swarm setup with NFS mounts and there I cannot mount a file directly. If you need help testing I would volunteer with said docker swarm.
Collaborator

FYI, this will be part of #8.

# Optional: Path to the database.
# Useful if you need it mounted in a Docker volume. Keep in mind that it will not
# do any check on the existence of the path, or if it is dangerous.
# Default: "./app.db"
# DATABASE_PATH="/var/lib/bricktracker/app.db"

image

FYI, this will be part of #8. ``` # Optional: Path to the database. # Useful if you need it mounted in a Docker volume. Keep in mind that it will not # do any check on the existence of the path, or if it is dangerous. # Default: "./app.db" # DATABASE_PATH="/var/lib/bricktracker/app.db" ``` ![image](/attachments/a7ef3a2f-295f-4041-bc7d-814f1a315eb0)

This is implemented in e2425a106a

This is implemented in e2425a106a
Sign in to join this conversation.
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: FrederikBaerentsen/BrickTracker#23
No description provided.