Open Denney-tech opened 3 months ago
The collectstatic
django command is already executed during the galaxy_ng container build
https://github.com/ansible/galaxy_ng/blob/master/Dockerfile.rhel8#L52
However, without any value for STATIC_ROOT
at build time (ie: via PULP_STATIC_ROOT
environment variable) then the DRF files are generated into the default pulp assets directory: /var/lib/pulp/assets
$ podman run --rm quay.io/ansible/galaxy-ng:latest ls -lh /var/lib/pulp/assets
total 12K
drwxr-xr-x 6 root root 4.0K Jun 26 15:28 galaxy_ng
drwxr-xr-x 2 root root 4.0K Jun 26 15:28 import_export
drwxr-xr-x 7 root root 4.0K Jun 26 15:28 rest_framework
$ podman run --rm quay.io/ansible/galaxy-ng:latest ls -lh /app/galaxy_ng/app/static
total 4.0K
drwxr-xr-x 6 1001 127 4.0K Jun 24 14:43 galaxy_ng
Not sure why we have both galaxy_ng static files in /var/lib/pulp/assets
and /app/galaxy_ng/app/static
directories.
The real fix would be to change the STATIC_ROOT
value in the operator to use /var/lib/pulp/assets or change the container build configuration to set PULP_STATIC_ROOT
on /app/galaxy_ng/app/static.
As a workaround, you should be able to solve this via the pulp_settings
override.
apiVersion: galaxy.ansible.com/v1beta1
kind: Galaxy
metadata:
name: galaxy
namespace: galaxy
spec:
pulp_settings:
static_root: /var/lib/pulp/assets
@rooftopcellist What do you think about this ?
@dsavineau Looks like your snippet works for me! Thank you, I wasn't sure what the static root should be when I was debugging, or why commenting out the setting altogether didn't work.
Version galaxy_ng: v4.10.0dev galaxy-operator: v2024.5.8
Describe the bug All of the "/static/rest_method/css/*" links are returning a 404 when browsing the api (or curling the api with
?format=api
)To Reproduce Deploy Galaxy with galaxy-operator (this is actually important, see below)
Expected behavior CSS links work and api pages render successfully.
Additional context In order for the CSS links to work for the API, the whitenoise django plugin needs to collect static assets into the
STATIC_ROOT
directory. (which you have hardcoded to/app/galaxy_ng/app/static/
This means running
django-admin collectstatic --noinput
to copy missing assets to the appropriate destination.Running this command appears to be required for all deployments, whether they are docker deployments or otherwise standalone deployments. The image itself does not necessarily run this step because there are different profiles for different deployment scenarios.
See profiles: https://github.com/search?q=repo%3Aansible%2Fgalaxy_ng%20django-admin%20collectstatic&type=code
To workaround this in the meantime, I have disabled the galaxy-operator, and modified the api deployment with the following changes:
I tried to run this in an initContainer, but the collected static assets didn't persist into the api container. I've also tried commenting out the
STATIC_ROOT
setting, but that didn't resolve the missing assets.