Live data from Hacker News

Shrinking my static site

hampton.pw

81–90 of 107 posts

Re: Shrinking my static site

#81

in my eyes this is all madness. deploying sites via github to some docker shit. how about good old ftp and a cheap shared webhost? like its been done for 30 years.

If there's a blog post: "I got my Ford F-350 to use less fuel by using this One Weird Trick", it's not much use to say how a Honda Civic is a much more simple and efficient solution to the given problem; the domain has already been defined to be the complicated solution.

I'd probably choose the sftp and webhost route myself, but you know.

Re: Shrinking my static site

#82

Earlier quoted context omitted.

Could you elaborate on that statement, why should static site and docker not be seen together?

It depends what you’re optimizing for. One of the beautiful things about a static site is it’s ability to be served by object stores like S3 as your origin, and cached by a CDN. From an operations standpoint, you are not responsible for maintaining much of anything, the performance is super fast, highly available, and relatively cheap (no dedicated servers, just paying for bandwidth and storage costs) Contrast that w…

Docker is nice because you end up with the same configuration in development and production. There are many hidden details that "just let someone else host your site" or "just rsync your files to a server" gloss over. Who is renewing your TLS certificate? Where do you configure headers, redirects, mime type mappings, etc.? Where do access logs go? How do you update the version of the web server? What effects does that update have?

When you manually do these things, you rely on a bunch of implicit defaults. Maybe your production server and your workstation happen to have the same version of nginx, and happen to set the same defaults. So you can test a change on your workstation and the same change works in production. But more likely, that is not the case. So you get weird differences between development and production, and you only notice when you push to production. That is not ideal. Building an image with your webserver and static files ensures that you see the same things in both places. There is no need to test anything in production, as you have a copy of the exact code and data that is going to be running in production, locally. You can tweak and poke to your heart's content, confident that you'll have the same effect when you push to production. There is no need to maintain documentation about how to build your project and what versions of things you use; you specify them in a machine-readable format and the machine dutifully builds the project correctly every single time.

(One disadvantage of clean builds, though, is that sometimes you want old artifacts to exist. Consider a case where you use webpack to generate javascript. Typically, you'll output a bundle like "main.abc123.js" which is loaded from "index.html" via a script tag. What happens when the browser loads index.html from your last build, then you the next request goes to an updated server, which says to get "main.def456.js" instead? The page silently breaks, because the server doesn't have a file called "main.def456.js" anymore. "rsync --delete" has the same problem. And if you never delete anything, you eventually use an infinite amount of disk space. So there is definitely room for improvement here, but "it will probably work if I don't think about it and cross my fingers" is not the improvement we're looking for.)

Re: Shrinking my static site

#83
post #7

I use Hugo as my static site generator, single binary, no dependencies, generating hundreds of pages in milliseconds ... so reading this feels so wrong, I want to call it JavaScript masochism. Taking a simple concept like a static site and adding a ton of complex tooling around it because it is the trend now? Why would you even need a docker image to run a static website? The best thing about a static website us you…

I just looked at Hugo. Their docs menu doesn't work with JS disabled. I know it's a tangent from the point of this thread, but it just makes me crestfallen.

https://gohugo.io/documentation/

Re: Shrinking my static site

#84
post #7

I use Hugo as my static site generator, single binary, no dependencies, generating hundreds of pages in milliseconds ... so reading this feels so wrong, I want to call it JavaScript masochism. Taking a simple concept like a static site and adding a ton of complex tooling around it because it is the trend now? Why would you even need a docker image to run a static website? The best thing about a static website us you…

Speaking of complex tooling you don't think Hugo is a bit complex itself?

Took Hugo for a test drive using official quick start.

Half the themes from official docs wouldn't compile.

Started looking into architecture but official docs do not explain the big picture just a bunch of instructions.

The official documentation does not explain on what is going behind the scenes very well.

I mean, I will obviously want some sort of scaffolding and a way of changing it but this https://gohugo.io/getting-started/directory-structure/ is not helping very much.

Since you are not supposed to write go code everything has to be done through .toml config files as far as I could grok.

I feel I'd rather write my own static generator in language of my choice(say Python) than keep up with the Hugo docs.

Re: Shrinking my static site

#85
post #33

I'd suggest changing this: COPY package.json . RUN npm install to this: COPY package.json package-lock.json . RUN npm ci `npm ci` installs the exact dependencies specified in the lockfile. This way, transitive dependencies that were upgraded via `npm audit fix` are guaranteed to be installed. It therefore forces the image to be rebuilt when a transitive dependency changes. Copying only the package.json wouldn't do th…

+1. npm ci is typically quite a bit faster too in my experience.

Re: Shrinking my static site

#87
post #84
post #7

I use Hugo as my static site generator, single binary, no dependencies, generating hundreds of pages in milliseconds ... so reading this feels so wrong, I want to call it JavaScript masochism. Taking a simple concept like a static site and adding a ton of complex tooling around it because it is the trend now? Why would you even need a docker image to run a static website? The best thing about a static website us you…

Speaking of complex tooling you don't think Hugo is a bit complex itself? Took Hugo for a test drive using official quick start. Half the themes from official docs wouldn't compile. Started looking into architecture but official docs do not explain the big picture just a bunch of instructions. The official documentation does not explain on what is going behind the scenes very well. I mean, I will obviously want some…

For simple websites you need no "scaffolding", you can just edit the html in a text editor. Really just write the text between the tags. Better to meditate over simplicity and minimalism than to start another software project just to publish a blog.

Re: Shrinking my static site

#88

Earlier quoted context omitted.

Possibly this is far too old fashioned, but all our internal static sites (and a good few external static sites) I deploy to a single Apache server.

I highly recommend nginx over apache. It's both more performant AND much easier to configure. Other than inertia for an existing deployment I don't think there's any reason to use Apache in 2020.

These days if configured correctly there is not a huge amount of difference in performance between nginx and Apache. I have stayed with Apache because I know it and dealing with a http server is about 0.1% of my job.

Re: Shrinking my static site

#89
post #84
post #7

I use Hugo as my static site generator, single binary, no dependencies, generating hundreds of pages in milliseconds ... so reading this feels so wrong, I want to call it JavaScript masochism. Taking a simple concept like a static site and adding a ton of complex tooling around it because it is the trend now? Why would you even need a docker image to run a static website? The best thing about a static website us you…

Speaking of complex tooling you don't think Hugo is a bit complex itself? Took Hugo for a test drive using official quick start. Half the themes from official docs wouldn't compile. Started looking into architecture but official docs do not explain the big picture just a bunch of instructions. The official documentation does not explain on what is going behind the scenes very well. I mean, I will obviously want some…

It is complex. I found the documentation was not structured to naturally align with the discovery process I went through in learning how it works. I found myself reading the Go source and using a debugger to step through execution to get a better understanding. I had a similar first experience.
Post reply on HN