alexbates / Tamari

A fully-featured recipe manager web application built using Python and the Flask Framework.
https://tamariapp.com
GNU General Public License v3.0
68 stars 1 forks source link

Missing folder in appdata on startup #3

Closed karlomikus closed 4 months ago

karlomikus commented 4 months ago

I've had an error trying to save recipe from explore page:

tamari  | [2024-05-27 13:43:30,587] ERROR in app: Exception on /explore/recipe/all/14713 [POST]
tamari  | Traceback (most recent call last):
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 2190, in wsgi_app
tamari  |     response = self.full_dispatch_request()
tamari  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1486, in full_dispatch_request
tamari  |     rv = self.handle_user_exception(e)
tamari  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1484, in full_dispatch_request
tamari  |     rv = self.dispatch_request()
tamari  |          ^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1469, in dispatch_request
tamari  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
tamari  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask_login/utils.py", line 290, in decorated_view
tamari  |     return current_app.ensure_sync(func)(*args, **kwargs)
tamari  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask_limiter/extension.py", line 1303, in __inner
tamari  |     return cast(R, flask.current_app.ensure_sync(obj)(*a, **k))
tamari  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/app/explore/routes.py", line 1302, in exploreRecipeDetail
tamari  |     with open(app.config['UPLOAD_FOLDER'] + '/' + i_photo, 'wb') as outfile:
tamari  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  | FileNotFoundError: [Errno 2] No such file or directory: '/app/appdata/recipe-photos/4eb932400893f00d.jpeg'

My appdata volume is locally mounted:

name: recipes
services:
    tamari:
        restart: unless-stopped
        ports:
            - 4888:4888
        volumes:
            - ./tamariappdata:/app/appdata
        container_name: tamari
        image: alexbates/tamari:0.6

I've fixed it by manually creating a recipe-photos folder inside ./tamariappdata path.

I'm not sure if this is just some mistake on my end or is the error somewhere in the docker setup.

alexbates commented 4 months ago

I was not able to replicate this issue on multiple machines, but I get the exact same error when the recipe-photos directory is missing. It sounds like the contents of /app/appdata from the image were not copied to the volume, but there were no issues initializing the database and migrations directory with the entrypoint script.

I have pushed new images for v0.6 that will now create the recipe-photos directory (if it doesn't exist) and copy default photos every time the container boots (from boot.sh entrypoint script). Hope that fixes it!

karlomikus commented 4 months ago

I think that happens when you use local folders as volumes, they first get created locally and then they are mounted into container. So they are always empty inside the container.

Either way, thanks!