forked from LeineLab-Public/lab-signal-bot
main: move db to data/ such that docker does not create a directory
This commit is contained in:
parent
f3c0e0c363
commit
05bbf2f8d1
@ -58,3 +58,8 @@ Rebuild containers:
|
|||||||
```
|
```
|
||||||
docker compose up --build -d
|
docker compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Change the ownership of the db, such that the host user 1000 can write it:
|
||||||
|
```
|
||||||
|
sudo chown -R 1000 data/
|
||||||
|
```
|
||||||
|
@ -5,6 +5,7 @@ from result import Err, Ok, Result
|
|||||||
from models import Task
|
from models import Task
|
||||||
import argparse
|
import argparse
|
||||||
from sqlmodel import Session, SQLModel, create_engine
|
from sqlmodel import Session, SQLModel, create_engine
|
||||||
|
from main import *
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import dateparser
|
import dateparser
|
||||||
@ -55,9 +56,6 @@ if __name__ == "__main__":
|
|||||||
print("Invalid due date.", file=sys.stderr)
|
print("Invalid due date.", file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
engine = create_engine("sqlite:///data.db")
|
|
||||||
SQLModel.metadata.create_all(engine)
|
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
task = Task(
|
task = Task(
|
||||||
name=args.name,
|
name=args.name,
|
||||||
|
0
data/.keep
Normal file
0
data/.keep
Normal file
@ -12,4 +12,4 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
- "./config.json:/app/config.json"
|
- "./config.json:/app/config.json"
|
||||||
- "./data.db:/app/data.db"
|
- "./data:/app/data"
|
||||||
|
2
main.py
2
main.py
@ -546,7 +546,7 @@ async def main(config: Config, session: Session):
|
|||||||
with open("config.json", "r") as f:
|
with open("config.json", "r") as f:
|
||||||
config = Config.model_validate(json.load(f))
|
config = Config.model_validate(json.load(f))
|
||||||
|
|
||||||
engine = create_engine("sqlite:///data.db")
|
engine = create_engine("sqlite:///data/data.db")
|
||||||
SQLModel.metadata.create_all(engine)
|
SQLModel.metadata.create_all(engine)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user