Publish a static site to the edge

Over the last few months I’ve been playing with the JavaScript Static Publisher for Compute developed by our very own @harmony7 which lets you deploy an entire static site to the edge without using an origin host:

When I started exploring alternatives to Glitch for helping people to try Fastly Compute, I found the static publisher perfect for guided experiences in GitHub Codespaces, where you can develop a site in the browser and deploy it straight to the network edge at the click of a button:

This is a new type of experience for us so your feedback is much appreciated, please share in the thread if you try it!

For a more detailed guide to using the static publish flow for an existing website you have on your computer, check out the tutorial in Fastly docs (it’s so easy it’s literally a couple of commands to get your site online):

Once you have your website on the edge you can add your own domain to your service, and access observability stats right in your Fastly account. Let us know what you think! :megaphone:

4 Likes

Has anyone used this with Hugo?

I got as far as

FROM cgr.dev/chainguard/wolfi-base AS base
RUN apk add npm nodejs-24 curl
RUN npx @fastly/compute-js-static-publish@latest --help || true
WORKDIR /src/
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.150.1/hugo_0.150.1_linux-amd64.tar.gz | tar zxf -
RUN rm LICENSE README.md
RUN mv hugo /bin/
COPY . .
RUN hugo
RUN npx @fastly/compute-js-static-publish@latest --root-dir=./public --kv-store-name=site-content
WORKDIR /src/compute-js
RUN npm run dev:publish
EXPOSE 7676
ENTRYPOINT ["./node_modules/.bin/fastly", "compute", "serve", "--addr=0.0.0.0:7676"]

Which *seems* to work except because of the way Hugo works, everything points to my existing site and I’m not actually sure if the Fastly publisher is picking everything up.

This seems very complicated compared to Fastly’s competitors (at least for static sites).

I’ll run back through Publish your static site to the edge | Fastly Documentation again at some stage and see if I can adapt it.

I’d also note that this seems to download binary dependencies every time - it’d be good if there was a fastly dependencies command so I could do this once in my Dockerfile.

You will need to configure Hugo to generate relative, not absolute, links for all of its navigation so that you can test the completely-built site locally.

As far as dependencies go: if you are saving an image from the container built by this Dockerfile, you should be able to restart it without any dependencies being downloaded again. If you are just runing this Dockerfile, then the entire process must be repeated every time.

1 Like