-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle static assets using root directive #553
Comments
Hi, the easiest way is probably to run a web server inside the container for servering the assets and in turn that one proxies to puma etc. I guess it is doable but a bit tricky for nginx-proxy to server assets for another container, that would require it to share some filesystem volume etc. |
I'm stuck in the same spot, there must be a way to accomplish this, as you can override most things per virtual host setting. Anyone got any ideas? I really don't want to have another nginx container, that sounds a bit backwards. |
@mjdavies i think the tricky bit is how nginx-proxy would access the static assets. Share volume on the host or share volume between the containers? in my opinion both are quite ugly and also would require container recreate if a container is added/removed/changed |
Hi @wader After looking into it a bit more, I see what you mean. :-( I'm still a bit lost as to how to achieve the web server inside the container bit though. Puma or unicorn or thin are all running in web container, so create another nginx container that points at the web container? A bit lost, tis all. |
Hi again. My suggestion it to run two web servers inside the container. One nginx etc with a tiny config to serve static files and forward the rest to puma, unicorn etc. The static/forward web server is the only web server that will be accessible from outside, puma, unicorn will only listen locally or use unix socket etc. |
Thanks for replying @wader I've never seen anyone running two 'things' inside the one container before, it kind of breaks docker rules doesn't it? Having said that, I don't really care that much about the rules. if you have 2 minutes to knock up a quick docker-compose file to give me a rough idea of what you mean that would be really helpful, it doesn't have to work, just an idea of what you mean as I have none now. I'm attaching what I've got so far for a rails app, running locally in production mode(docker-entrypoint.sh kicks that off) Any tips on how to add another service to the container very much welcomed. |
HI @wader Sorry, must have been having a mental block yesterday, you mean install nginx and set it up inside the Dockerfile for the app, just like we're setting up puma or unicorn. Thanks for your help with this, it is appreciated. |
Something alot like this |
@mjdavies 👍 but i agree that it feels a bit backwards... but for a medium size ruby app i guess it is the simplest solution. All other solution i can think of gets very complicated 😄 |
I found the following to work -- I'm using django and it currently collects all the static content into a dir in its container, then I share it to the
When you use
Since I'm only serving one site, this seems to work well for me. I didn't realize it, but it would seem you can use nested |
This seems to be resolved by the last comment. If this is not the case, please reopen. |
I'm using this with rails running a puma server.
Rials is relying on nginx to serve static assets. Could you please explain how to set the
root /app/public;
setting on nginx config when using your automated image.The text was updated successfully, but these errors were encountered: