icbestCA / giftmanager

Gift ideas manager for families. See the demo here: https://giftmanagerdemo.pages.dev/
MIT License
72 stars 3 forks source link

[BUGS] Users return upon container restart. #9

Closed geraveoyomama closed 1 day ago

geraveoyomama commented 2 weeks ago

The issues I run into is that the demo users are deleted and custom users can be added, but when the container is stopped and started the original demo users return and /setup is not accessible on http://127.0.0.1:5000/setup.

When running in a container like so:


 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5000
 * Running on http://10.0.2.100:5000
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 394-483-947
10.0.2.100 - - [25/Aug/2024 14:39:34] "GET /dashboard HTTP/1.1" 200 -
10.0.2.100 - - [25/Aug/2024 14:39:35] "GET /static/icons/help.svg HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:35] "GET /static/icons/cart.svg HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:35] "GET /static/icons/mail.svg HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:35] "GET /static/icons/avatar2.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:35] "GET /static/icons/log-out.svg HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:35] "GET /static/icons/avatar1.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /add_user HTTP/1.1" 200 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /static/icons/avatar1.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /static/icons/avatar2.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /static/icons/avatar3.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /static/icons/avatar5.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /static/icons/avatar4.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:41] "GET /static/icons/avatar6.png HTTP/1.1" 304 -
10.0.2.100 - - [25/Aug/2024 14:39:56] "POST /add_user HTTP/1.1" 302 - 
icbestCA commented 2 weeks ago

I will check on my side, but it seems that changes aren't saved to the json, I know Flask run primarily in Ram, maybe there's writing permission missing for the JSON?

geraveoyomama commented 2 weeks ago

yeah just tested, it could be that it pulls a new image which contains template storage and overwrites the current storage.

It could be that it doesn't commit changes to disk after changes are made in RAM.

Or I have a misconfiguration...

I am working to see what I can do to fix it, e.g. pass a volume through as /app for GM to write to.

geraveoyomama commented 2 weeks ago

ok alrighty, since restarting with this command podman run -d --replace --name gift-manager --publish 5000:5000/tcp --annotation run.oci.keep_original_groups=1 --userns keep-id --volume app:/app:Z docker.io/icbest/giftmanager:latest and running with --volume app:/app:Z omitted I get one with custom users and one without custom users respectively

geraveoyomama commented 2 weeks ago

got a message!

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1498, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1476, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/app.py", line 44, in decorated_function
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/app/app.py", line 579, in add_user
    with open('users.json', 'w') as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'users.json'
geraveoyomama commented 2 weeks ago

after setting rw,z on the volume and manually editing the users.json to remove the trial users it is showing up correctly

geraveoyomama commented 2 weeks ago

podman run -d --replace --name gift-manager --publish 5000:5000/tcp --volume app:/app:rw,Z docker.io/icbest/giftmanager:latest

is a working command with persistent storage in the podman app volume

after editing users.json

icbestCA commented 2 weeks ago

Thanks, didn't used Podman, but glad you were to solved it.

geraveoyomama commented 2 weeks ago

well regardless if podman is a drop in replacement for docker then I wonder if in the future it will behave in the same way on docker