I’m currently researching the best method for running a static website from Docker.
The site consists of one single HTML file, a bunch of CSS files, and a few JS files. On server-side nothing needs to be preprocessed. The website uses JS to request some JSON files, though. Handling of the files is doing via client-side JS, the server only need to - serve the files.
The website is intended to be used as selfhosted web application and is quite niche so there won’t be much load and not many concurrent users.
I boiled it down to the following options:
- BusyBox in a selfmade Docker container, manually running
httpd
or The smallest Docker image … php:latest
(ignoring the fact, that the built-in webserver is meant for development and not for production)- Nginx serving the files (but this)
For all of the variants I found information online. From the options I found I actually prefer the BusyBox route because it seems the cleanest with the least amount of overhead (I just need to serve the files, the rest is done on the client).
Do you have any other ideas? How do you host static content?
CameronDev@programming.dev 8 months ago
Just go nginx, anything else is faffing about. Busybox may not be security tested, so best to avoid on the internet. Php is pointless when its a static site with no php. Id avoid freenginx until its clear that it is going to be supported. There is nothing wrong with stock nginx, the fork is largely political rather than technical.
Dirk@lemmy.ml 8 months ago
Absolutely, but it has a built-in webserver that can serve static files, too (I constantly use that in my dev environment).
But I guess you’re mostly right about just using Nginx. I already have multiple containers running it, though. Most of them just serving static files.
CameronDev@programming.dev 8 months ago
Having PHP installed is just unnecessary attack surface.
Are you really struggling for space that 50mb matters? An 8gb usb can hold thar 160x?
lemmyvore@feddit.nl 8 months ago
How about Python? You can get an HTTP server going with just
python3 -m http.server
from the dir where the files are. Worth remembering because Python is super common and probably already installed in many places (be it on host or in containers).