this post was submitted on 05 Mar 2024
51 points (91.8% liked)

Selfhosted

40359 readers
293 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

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:

  1. BusyBox in a selfmade Docker container, manually running httpd or The smallest Docker image ...
  2. php:latest (ignoring the fact, that the built-in webserver is meant for development and not for production)
  3. 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?

you are viewing a single comment's thread
view the rest of the comments
[–] CameronDev@programming.dev 35 points 8 months ago (12 children)

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 4 points 8 months ago* (last edited 8 months ago) (11 children)

Php is pointless when its a static site with no php

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. But it's ca. 50 megabytes compressed size each container just for Nginx alone.

[–] lemmyvore@feddit.nl 1 points 8 months ago (3 children)

Absolutely, but it has a built-in webserver that can serve static files, too (I constantly use that in my dev environment).

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).

[–] Dirk@lemmy.ml 1 points 8 months ago (1 children)

I once built a router in Python, but it was annoying. The much I like Python, the much I dislike coding in it. Just firing up a web server with it is no big deal, though.

I was even thinking of node.js, but this comes with a whole different set of issues. It would allow for future extensions of the project on the server-side, though.

[–] lemmyvore@feddit.nl 1 points 8 months ago (1 children)

What do you use for Node containers? I use an Alpine image where I install Node but I've been wondering if there's a better way.

[–] Dirk@lemmy.ml 1 points 8 months ago

Would be my first one. I'd likely go the Alpine route, too. It's used as option for the Docker official image.

https://hub.docker.com/_/node/tags?page=1&name=alpine

load more comments (1 replies)
load more comments (8 replies)
load more comments (8 replies)