Why? It seems like docker is way more flexible and maintainable.
Comment on Best way to dockerize a static website?
ptman@sopuli.xyz 8 months ago
Forget about docker. Run caddy or some similar webserver that is a single file next to the assets to serve.
possiblylinux127@lemmy.zip 8 months ago
jj4211@lemmy.world 8 months ago
Because serving static files doesn’t really require any flexibility in web serving code.
If your setup has an nginx or similar as a reverse proxy entry point, you can just tell it to serve the directory. Why bother making an entire new chroot and proxy hop when you have absolutely zero requirements beyond what the reverse proxy already provides. Now if you don’t have that entry point, fine, but at least 99% of the time I see some web server as initial arbiter into services that would have all the capability to just serve the files.
possiblylinux127@lemmy.zip 8 months ago
How will it scale though?
smileyhead@discuss.tchncs.de 8 months ago
My brother in Christ, serving a file through HTTP is exactly what Tim Berners-Lee invented in 1989.
jj4211@lemmy.world 8 months ago
For 90% of static site requirements, it scales fine. That entry point reverse proxy is faster at fetching content to serve via filesystem calls than it is at making an http call to another http service. For self hosting types of applications, that percentage guess to go 99.9%
If you are in a situation where serving the files through your reverse proxy directly does not scale, throwing more containers behind that proxy won’t help in the static content scenario. You’ll need to do something like a CDN, and those like to consume straight directory trees, not containers.
For dynamic backend, maybe. Mainly because you might screw up and your backend code needs to be isolated to mitigate security oopsies. Often it also is useful to manage dependencies, but that facet is less useful for golang where the resulting binary is pretty well self contained except maybe a little light usage of libc.
Dirk@lemmy.ml 8 months ago
I already have a fully set up docker environment that serves all sorts of things (including some containers that serve special static content using Nginx).
sudneo@lemmy.world 8 months ago
Containers are a perfectly suitable use-case for serving static sites. You get isolation and versioning at the absolutely negligible cost of duplicating a binary (the webserver - which in case of the one I linked in my comment, it’s 5MB of space). Also, you get autostart of the server if you use compose, which is equivalent to what you would do with a Systemd unit, I suppose.
You can then use a reverse-proxy to simply route to the different containers.
jj4211@lemmy.world 8 months ago
But it you already have an nginx or other web server otherwise required to start up (which is in all likelihood the case), you don’t need any more auto startup, the “reverse proxy” already started can just serve it. I would say that container orchestration versioning can be helpful in some scenarios, but a simple git repository for a static website is way more useful since it’s got the right tooling to annotate changes very specifically on demand.
That reverse proxy is ultimately also a static file server. There’s really no value in spinning up more web servers for a strictly static site.
Folks have gone overboard assuming docker or similar should wrap every little thing. It sometimes adds complexity without making anything simpler. It can simplify some scenarios, but adding a static site to a webserver is not a scenario that enjoys any benefit.
sudneo@lemmy.world 8 months ago
It really depends, if your setup is docker based (as OP’s seems to be), adding something outside is not a good solution. I am talking for example about traefik or caddy with docker plugin.
By versioning I meant that when you do a push to master, you can have a release which produces a new image. This makes it IMHO simpler than having just git and local files.
I really don’t see the complexity added, I do gain isolation (sure, static sites have tiny attack surfaces), easy portability (if I want to move machine it’s one command), neat organization (no local fs paths to manage essentially), and the overhead is a 3 lines Dockerfile and a couple of MB needed to duplicate a webserver binary. Of course it is a matter of preference, but I don’t see the cons honestly.
smileyhead@discuss.tchncs.de 8 months ago
Serving static app in Caddy:
sudo apt install caddy sudo systemctl enable --now caddy
Then in /etc/caddy/Caddyfile:
That’s all, really.
sudneo@lemmy.world 8 months ago
If there is already another reverse proxy, doing this IMHO is worse than just running a container and adding one more rule in the proxy (if needed, with traefik it’s not for example). I also build all my servers with IaC and a repeatable setup, so installing stuff manually breaks the model (I want to be able to migrate server with minimal manual action, as I had to do it already twice…).
The job is simple either way, I would say it mostly depends on which ecosystem someone is buying into and what secondary requirements one has.