问题
The goal:
Make newly created Laravel6 projects' bootstrap assets layout work from Docker.
Symptoms: Bootstrap assets work properly on local Laravel development environment (XAMPP -Apache- +Win10Pro), both the js and css are loaded well. But does'not work properly from local Docker (Win10-linux containers, Nginx+PHP+MySql+Redis), app.js and app.css runs on error 404.
Apache(local xampp):
Nginx(Docker):
What I did:
- New Laravel project created, auth added, bootstrap, npm and node installed properly.
Virtual Host settings (httpd-vhosts.conf) for Apache in xampp:
- nginx.conf in nginx container
Virtual Host settings (default.conf) for Nginx in nginx container:
.htaccess file in my projectfolder /a_new_app_for_test/public/
- docker-compose.yml for nginx
- docker-compose.yml for app
What settings should I add/change in order to make assets loaded correctly?
I suppose it could be related to nginx settings compiled into Docker.
Any help are appreciated.
Thanks in advance.
回答1:
Try to copy your whole project to the container volume, this way nginx will be able to see your files from public or resources folder.
volumes:
- ./:/var/www/
来源:https://stackoverflow.com/questions/61271923/bootstraplaravel-assets-404-error-from-dockernginx