savoirfairelinux / sous-chef

Sous-Chef is a web application to help organizations to plan and deliver meals, and to manage clients files.
GNU Affero General Public License v3.0
67 stars 45 forks source link

Strange staticfiles behaviour #765

Closed kousu closed 7 years ago

kousu commented 7 years ago

I just tried putting sous-chef up again using docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d, which runs /bin/bash -c "cd tools/gulp && npm install && gulp && cd ../../src && python manage.py collectstatic --noinput && /usr/local/bin/gunicorn sous_chef.wsgi:application -w 2 -b :8000. Strangely, this did not create the staticfiles properly; for example http://localhost:8000/static/images/logo-souschef-coul.png was 404'ing.

I re-ran docker-compose exec web "cd tools/gulp && npm install && gulp" and then it worked.

There are three copies of the static files:

root@a375081c9a66:/code# find -name logo-souschef-coul.png
./src/frontend/images/logo-souschef-coul.png
./src/static/images/logo-souschef-coul.png
./src/sous_chef/static/images/logo-souschef-coul.png

I think, but haven't fully tested yet, that src/frontend is the source folder, src/static is made by collectstatic, and src/sous_chef/static/ is made by gulp and is the one generated by gulp, and furthermore perhaps collectstatic is erasing it, which means gulp && cd ../../src && python manage.py collectstatic --noinput should rather be python manage.py collectstatic --noinput && cd ../tools/gulp && gulp or maybe even just gulp.

Does anyone know what's going on here? The behaviour is very inconsistent and confusing.

lingxiaoyang commented 7 years ago

@kousu I never looked at collectstatic but I doubt if it still works as we have been using gulp for quite a while. I'll let you know.

kousu commented 7 years ago

Thanks @lingxiaoyang; I think it should be perfectly reproducible if you start from a fresh checkout and run with the production settings

git clone https://github.com/savoirfairelinux/sous-chef/ sous-chef-prodtest
cd sous-chef-prodtest
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
erozqba commented 7 years ago

@kousu yes, we have a bug there! I will look into it.

erozqba commented 7 years ago

@kousu this bug has been fixed in PR #775 You could check it from a fresh checkout using this commands:

git clone https://github.com/savoirfairelinux/sous-chef/ sous-chef-prodtest
cd sous-chef-prodtest
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
docker-compose exec web sh -c "python src/manage.py migrate"
docker-compose exec web sh -c "python src/manage.py createsuperuser"
docker-compose exec web sh -c "python src/manage.py loaddata sample_data"

Then add the hostname "souschef.santropolroulant.org" in your /etc/hosts 127.0.0.1 souschef.santropolroulant.org And check it out in a browser http://souschef.santropolroulant.org/

Note: The Hostname http://souschef.santropolroulant.org/ could be changed in the docker-compose.prod.yml

I'm closing this issue, you could reopen it if you find any problems.