-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Adding the ability to serve static files #1037
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
base: main
Are you sure you want to change the base?
Conversation
This is done by intruducing a new VIRTUAL_PROTO=static. The VIRTUAL_ROOT variable points to the static root which should be mounted into the container as volume. Often the container of the static website does not need to run, so I introduced a new environment variable INCLUDE_STOPPED_CONTAINERS that adds the -include-stopped flag to docker-gen
… is not set This prevents the passing of arbitrary flags to docker-gen
|
I could have avoided having to spin up a dummy python web server to serve the assets if this had been available - looking forward to having this feature merged in! |
|
I'm still interested in seeing this merged in. I updated the branch to be up-to-date with the upstream branch. |
|
Why this is not pulled in yet? is this project dead? |
|
any updates? |
|
The biggest problem I see with this attempt is that it still requires that the volume with the static content be mounted into the The end result is that you have configuration split between two containers (or
I love the automatic configuration that |
# Conflicts: # nginx.tmpl
|
I'm probably missing a point here, but what avantage does this approach have over serving those static files from another nginx container behind nginx-proxy ? |
The advantage is precisely that: avoiding the need to spin up another instance of nginx solely for the use-case of serving static assets. I would imagine same argument could be made for the uWSGI/FastCGI backends - what advantage does including those directly within This is exactly why I responded to the PR with:
I'm not sure what the limitations of the Docker client SDK are (I can dig more later), but is it possible for docker-gen to update the volume mounts for a running container? That could theoretically address the concern that @JonathonReinhart raised regarding having to manually mount volumes within the |
@dhm116 I think it's easier to start with the question: "Is is possible to add a volume mount to a running container?" The answer, I'm fairly certain, is unfortunately "No."
So unless you want |
Regarding this part, no there is no way to live update volumes on a running container. You have to stop it, re-create the container with the new volume and start it again. Regarding docker-gen, it is not meant to change anything on running container beside signaling them after a template rendering. |
|
Thanks for the insights @JonathonReinhart and @buchdag, very much appreciated. My gut was telling me that it wasn't possible, but I was hoping for something within the SDK that I was unfamiliar with 😞 I think I would tend to agree that having to explicitly mount volumes to the Would an approach where |
You still have to create a stopped container just to act as a support for the environment variable (if it's not stopped, I guess it kinda defeat the whole feature's point). In contrast, if you're planning on using WSGI/FastCGI your backend container does exist and run, wether nginx-proxy is able to natively proxy this protocol to the backend or not. I get that serving static file straight from nginx-proxy might be useful and the parallel made with the uWSGI/FastCGI backends but I'm really not sold on having to use stopped and/or useless containers to achieve this. |
|
Regarding the volumes / |
I have come across the problem, that I have one webserver where I want to mix my web-apps with some static websites. As I really like the easy, pluggable way of setting my web-apps up with nginx-proxy (+ let's encrypt companion), I wanted to use this infrastructure to also serve my static files.
I therefore added a new backend that configures nginx to directly serve static files from a mounted volume in the nginx-proxy container.
To allow for static containers to be stopped, I also added the possibility to include stopped containers via an environment variable.