Open venom85 opened 2 years ago
I also deleted all static assets in an attempt to get it to recreate everything. It spent a while running collectstatic, which created the full collection of static assets in /home/wger/static. After that, though, the results are the same. It looks like I have Django misconfigured, I just don't know how or what to even look for.
Hi! You need to setup a webserver to serve the static files, django does not serve them on its own. Did you change something to make the app run on Kubernetes? If yes, you need to need to do something similar to this https://github.com/wger-project/docker/blob/master/nginx/nginx.conf
Ah, that makes more sense. Apologies for my ignorance!
I didn't actually change anything in the container(s) to run in Kubernetes. I have the main wger/server container as the primary image in the pod, and Postgres and Redis are sidecars dedicated to the app. All persistent data (static and media assets as well as the PG DB) is stored on an NFS server, and all configuration is done via environment variables. I was successfully serving up the app (minus the static assets) via an ingress controller pointed to port 8000 on the pod.
After this, it sounds like I also need to throw a Nginx sidecar into the pod. That should serve up the static assets and render things properly. Thanks for the guidance!
BTW, you might want to take a look at this PR, somebody from the community is adding support for helm charts to deploy to Kubernetes:
Closing this issue to avoid clutter but if there's still something not working, just open it again
re-opening because i was following https://github.com/wger-project/wger/blob/master/extras/docker/development/README.md and hit this same problem. the readme doesn't talk about this. it probably should. but i'm not sure what it should say. maybe something like "running without static files is mainly useful if you only want to test the api server" ? but most people would want to use static files, even if it's just to log in?
i would add there seems to be a lot of ways to run wger (wger/extras/docker/demo, wger/extras/docker/development, https://github.com/wger-project/docker) the former two run single wger images, so they don't have functioning static files. perhaps we should never recommend to run single images, and always use a docker-compose stack?(docker-compose now comes with docker anyway)
EDIT: here's another reason for that: the OFF importer needs a docker compose stack also
Why not just let Django serve static files?
When running in a Docker container on Kubernetes, I am seeing errors about not being able to find static assets like CSS and Javascript files. It was originally running correctly, and I'm not sure at all what changed when it stopped finding them. I have all static assets stored on a persistent volume mounted to /home/wger/static in the container. The K8s deployment is configured with the DJANGO_STATIC_ROOT environment variable, and the volume is accessible from the container.
I will be happy to provide any additional information about my setup. I honestly don't really know how to test or verify the static assets within Django specifically, though. Here are some screenshots of examples of what I have configured and what I see, but I can copy the full deployment configuration if needed.