spetrovi / songbook

GNU General Public License v3.0
2 stars 0 forks source link

Preserve DB files on different runs when the app is containerized #18

Closed inknos closed 6 months ago

inknos commented 10 months ago

While working with the container it came to mind that the db files could be separate from the container. I am not sure if this is a real issue, but it needs to be verified.

What should be possible to be achieved is the following

$ podman run ... -v $(pwd)/test-database:/database/path:Z songbook:latest
spetrovi commented 10 months ago

Ok I included this line in Dockerfile:

RUN python3 /code/app/songs/importer.py

And edited the importer so it actually creates the library.db where the app expects it. I tested on a separate machine, to see if it builds on a clean system and found out lilypond isn't friendly with relative paths, so I fixed that also. Should build and run the server now.

Please test!

inknos commented 10 months ago

works, two more things are needed for better user experience.

  1. I would drop these messages from the build part. Maybe they can be moved to DEBUG?
    
    2023-12-20 16:59:34,086 INFO sqlalchemy.engine.Engine [generated in 0.00008s] [('230ff814612c4e98ae628b1af584d7c6', 'Dobre ti je, Janku', 'scoredata 
    = {\n  \\version "2.24.1"\n  \\clef violin\n  \\key c \\major\n  \\time 4/4\n\\relative c\'\'{\ng16 g8. a16 d,8. e4 c4 f16 f8. g16 f8. d4 g ... (226 
    characters truncated) ...  len16 si8. se16 -- díš8. v_chlád4 -- ku4.}\n\n\\score {\n  <<\n    \\new Staff \\scoredata\n    \\new Lyrics \\scorelyrics
    \n  >>\n  \\layout{ }\n}\n', 'Dobre ti je Janku, v tom trenčanském zámku.\nNeoreš, neseješ, len si sedíš v chládku.\n\nNežádaj si milá, takovej dobro
    ty,\naby ti hrkaly ze železa boty.\n\nZe železa boty a na ruce púta,\nveď je to má milá, velmi zlá robota.\n', '515de15fd79f4afb824c833a4157d063', No
    ne), ('ff1d283a452046fa9fd16964ada1fb10', 'Ej, Bože nás požehnaj', "scoredata = {\n  \\clef violin\n  \\key c \\major\n  \\time 4/4\n\\relative c''{\
    nc8 c8 c4 d e4 d8. b16 c2 g'4 g g a g f2 d4\ng g g f e2 d4 c2 c4 e e d e d c2\n}\n}\n\n\n\\score {\n  <<\n    \\new Staff \\scoredata\n  >>\n  \\layo
    ut{ }\n}\n", 'Ej, Bože nás požehnaj, ej všecko nám dobré daj.\nej najprv dobré zdraví ej, potom požehnaní.\n', '515de15fd79f4afb824c833a4157d063', No
    ne), ('42862a12033b41eb8477f59934e9a665', 'Ej, ty trnavští páni', "scoredata = {\n  \\clef violin\n  \\key c \\major\n  \\time 7/4\n\\relative c''{\n
    g4 g8 g f g a4 g2 g4 f8 f g g f e \\tuplet 3/4 {e4 d c} g' g8 g g g f4 e d2 c\n}\n}\n\n\n\\score {\n  <<\n    \\new Staff \\scoredata\n  >>\n  \\layo
    ut{ }\n}\n", 'Ej, ty trnavští páni,\nej dívajú sa z brány,\nco delá Janýček\npod šibenicami\n\nCo by robil, visí,\nkeď zavinyl mosí,\nkošelka mu zmok

...


2. I would change this line
https://github.com/spetrovi/songbook/blob/main/Dockerfile#L23
to serve port 8080

the reason is convenience. once you start the container you get
```log
Success: compilation successfully completed
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)

it is likely that a user will bind the port to a non-root one, like podman run -p 8080:80 .... with this solution, clicking on the link will open the wrong url. I propose to change it to 8080 and document to bind to the same rootless port.

spetrovi commented 9 months ago

Turns out the log storm from 1. can be easily fixed by laving out echo=True at the engine creation. I don't even know how it got ther in the first place.