libreosteo / LibreOsteo

Open Source software for osteopathes
GNU General Public License v3.0
30 stars 18 forks source link

Downloading files/document is not possible for docker littlejoe 0.6.0 image #260

Closed lthreva closed 3 years ago

lthreva commented 3 years ago

Hello,

I don't know if there is another way to get support (I opened the Mattermost channel, but it seems empty). So I try to fill an issue.

My setup is:

This setup is working well since some years now, but as I migrated to version 0.6.0 and tested the documents feature, I have a problem.

The upload part is working well :

The download part is not working, I get an 500 error.

Here is an extract of log files: 2021-04-04 22:10:11,435 [ERROR] django.request: Internal Server Error: /files/documents/xxxxx.pdf Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 172, in _get_response resolver_match = resolver.resolve(request.path_info) File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 394, in resolve raise Resolver404({'tried': tried, 'path': new_path}) django.urls.exceptions.Resolver404: {'tried': [[<RegexURLPattern None ^$>], [<RegexURLResolver <RegexURLPattern list> (None:None) ^api/>], [<RegexURLResolver <RegexURLPattern list> (admin:admin) ^admin/>], [<RegexURLPattern login ^accounts/login/$>], [<RegexURLPattern logout ^accounts/logout>], [<RegexURLPattern accounts-create-admin ^accounts/create-admin/$>], [<RegexURLPattern install ^install/$>], [<RegexURLResolver <module 'rest_framework.urls' from '/usr/local/lib/python3.6/site-packages/rest_framework/urls.py'> (rest_framework:rest_framework) ^api-auth/>], [<RegexURLPattern statistics_view ^api/statistics[/]?$>], [<RegexURLPattern patient_document_view ^api/patients/(?P<patient>.+)/documents$>], [<RegexURLPattern None ^myuserid>], [<RegexURLPattern db_dump ^internal/dump.json>], [<RegexURLPattern load_dump ^internal/restore>], [<RegexURLPattern rebuild_index ^internal/rebuild_index>], [<RegexURLPattern None ^web-view/partials/patient-detail>], [<RegexURLPattern None ^web-view/partials/doctor-modal>], [<RegexURLPattern None ^web-view/partials/add-patient>], [<RegexURLPattern None ^web-view/partials/examinations-timeline>], [<RegexURLPattern None ^web-view/partials/examination>], [<RegexURLPattern search_view ^web-view/partials/search-result>], [<RegexURLPattern None ^web-view/partials/user-profile>], [<RegexURLPattern None ^web-view/partials/dashboard>], [<RegexURLPattern None ^web-view/partials/officeevent>], [<RegexURLPattern None ^web-view/partials/invoice-modal>], [<RegexURLPattern None ^web-view/partials/add-user-modal>], [<RegexURLPattern None ^web-view/partials/set-password-modal>], [<RegexURLPattern None ^web-view/partials/office-settings$>], [<RegexURLPattern None ^web-view/partials/import-file$>], [<RegexURLPattern None ^web-view/partials/rebuild-index$>], [<RegexURLPattern None ^web-view/partials/filemanager$>], [<RegexURLPattern None ^web-view/partials/restore$>], [<RegexURLPattern accounts-register ^web-view/partials/register$>], [<RegexURLPattern None ^web-view/partials/invoice-list$>], [<RegexURLPattern invoice_view ^invoice/(?P<invoiceid>\d+)$>], [<RegexURLPattern None ^web-view/partials/confirmation>], [<RegexURLPattern javascript-catalog ^jsi18n/$>]], 'path': 'files/documents/xxxx.pdf'} error_500_logs.log

I don't know how libreosteo is serving this content, am I supposed to setup a server to serve this content or should libreosteo serve the files as any pages?

I have the problem with a production server, but I have the same error with a new 0.6.0 container and a fresh database.

Could you please help me and at least give some indication about how to solve the problem?

How to reproduce:

Regards,

jbgury commented 3 years ago

Not sure that both issue are linked... First, the embedded http server try to delivery a 404 error on the document request. Probably because, even if it is mounted, the document seems to not be visible by the app. Do you have the issue after restarting the container ? Second, when trying to render the 404 page, it encountered an error. From your log, it points again on bower_components for Javascript dependencies.

I checked into the tag and indeed the 404 page contains error and try to load dependency on bower_components : https://github.com/libreosteo/LibreOsteo/blob/250deffd233716b3729ce6eb6d62caa1be546808/templates/404.html#L423 The application page loads dependencies on "components" path which is the right path (https://github.com/libreosteo/LibreOsteo/blob/250deffd233716b3729ce6eb6d62caa1be546808/templates/index.html#L153) It is the cause of your 500 issue. Fixed on the master, thanks. For your 404 resolution on documents I think that it is a trouble with volume and container

jbgury commented 3 years ago

The docker image was pushed with the update (into the tag latest)

jbgury commented 3 years ago

I opened the Mattermost channel, but it seems empty)

It does not mean that it does not work, user support is enabled on Mattermost channel !

jbgury commented 3 years ago

Duplicate of #228

lthreva commented 3 years ago

It is the cause of your 500 issue. Fixed on the master, thanks. For your 404 resolution on documents I think that it is a trouble with volume and container

Thanks for the very quick answer. I'm a bit puzzled because I use littlejoe's images and I'm unsure how it translates to libreosteo's images.

I'll try to create a new compose file for the libreosteo's images, or to patch the existing container while live running, just to see if it correct the issue.

I'm wondering why the upload is working and not the download part. If i'm right, the upload part needs at least RW rights t the volume, so that the download part should have access. Something has to be wrong with the image.

Perhaps should I fork the repo, backport your patch to version 0.6.0, and then rebuild the image (it's quite difficult for me to see exactly which code is in the following image : https://hub.docker.com/layers/littlejo/libreosteo/0.6.0/images/sha256-2dff909f78c14fccf10286eea61a2a086c65fd78008e4b3c5c922642489aaff2?context=explore )

lthreva commented 3 years ago

Duplicate of #228

Sorry for that, didn't find this issue when searching for a solution.

To check the content of 0.6.0 tag, I tried the windows release. I get it running on my personal W10 pc, but the download part does not work too. There is another error (indeed no error at all, it's just spinning and the files isn't downloaded). Fun fact, 404 pages do work correctly for the windows version, when I try to change urls. I tried to compare the content of the tar.gz and windows installation as it seems that the littlejoe's image is build with this archive: https://codeload.github.com/garthylou/Libreosteo/tar.gz/0.6.0 but Winmerge didn't found any evidence of big changes. It seems that I'm better doing the following:

Regards,

jbgury commented 3 years ago

On windows,download part should work. There are lot and lot users which are using it, on MacOS too. Différences for 404 page on windows could come from settings file and the compression enabling and debug flag To be checked

On other side you can try with the image https://hub.docker.com/r/libreosteo/libreosteo-http this is the current master build

lthreva commented 3 years ago

Hello, I prefer correcting my current 0.6.0 image because it means less test on my side to be sure that everything works as intended.

I could also wait for version 0.6.1, if something is on the way.

I tried to generate a new image but there are too many errors when I build.

So I tried to patch the container, to see what happens:

  1. I download docker for windows
  2. I have run littlejo images locally => the error is there
  3. I corrected the 404.html template and removed every bower references ( more than 5)
  4. I restarted the container
  5. I know have a beautiful 404 page ;-)
  6. The download error is present,

I now have file not found /files/documents/my_doc.pdf

regards

jbgury commented 3 years ago

I think that I understood the trouble. The application is served by "runserver" command from django. This command serves also media files only if the debug flag is True. In production mode, it should be served like a static files (with controlling authentication, I fixed this issue on the master for the 0.6.1 version)) When the image was built I think that debug was set to False, and that's why the request could not be served for /files/ urls.

Two solutions :

lthreva commented 3 years ago

Thanks for the awesome support!

Here are the steps I followed to "patch" the container:

  1. run the container and exec in the container
  2. set Debug to true in /Libreosteo/launch-libreosteo.sh
    • /Libreosteo $ grep DEBUG launch-libreosteo.sh
    • DEBUG = True
    • TEMPLATE_DEBUG = True
  3. remove bower in 404.html
    • sed -i -e "s/bower_//" /Libreosteo/templates/404.html
  4. restart container
  5. start and register admin test if ok
  6. docker commit
  7. docker push

This way I created an image on dockerhub on my own profile lthreva/libreosteo:0.6.0

I then reused the image in my swarm setup and the download part is now working.

I think the case can be closed, it was mainly caused by the image.

Thanks again for the support

jbgury commented 3 years ago

Great ! That's a good news 😊