clone

an offline sliding-block puzzle game in gleam and lustre, with an endless ladder of puzzles ranked by search

The deploy image has Node and no compiler

Dami committed e901cbd
Cloudflare Pages builds from the repository, and its image carries Go, Node, Bun,
Python and Ruby. It does not carry Gleam, so `gleam run -m lustre/dev build` on
its own is a command not found.

build.sh fetches the compiler instead: a single static binary, pinned to a
version because a toolchain that floats is a build that breaks on a day nobody
touched the repository, and checked against the published digest because a
download nobody verified is a download anybody can replace. Nothing needs Erlang
— the project targets JavaScript, so lustre/dev runs under Node and the compiler
is the only extra thing on the machine. The tests run before the build, so a
deploy cannot outrun them.

The project's build command becomes ./build.sh and its output directory dist.
commit
e901cbd18ae2c001f94e51f10db659c85e1f11f4
parent
b439fc8d2f99aad07a2147f45aa177b75cebd6fd
author
Dami <dami.etoile@gmail.com>
2 files changed, +43 -0
M.gitignore3++
Abuild.sh40++++++++++++++++++++++++++++++
M .gitignore +3 -0
A build.sh +40 -0
@@ -0,0 +1,40 @@
1+#!/usr/bin/env bash2+#3+# The Cloudflare Pages build. Its image carries Node and not Gleam, and the4+# compiler is a single static binary, so it is fetched rather than installed:5+# pinned to a version, because a toolchain that floats is a build that breaks on6+# a day nobody touched the repository.7+#8+# Nothing here needs Erlang. The project targets JavaScript, so `lustre/dev`9+# runs under Node and the compiler is the only extra thing on the machine.10+set -euo pipefail11+12+GLEAM_VERSION="1.18.1"13+ARCH="$(uname -m)"14+case "$ARCH" in15+ x86_64) TARGET="x86_64-unknown-linux-musl" ;;16+ aarch64 | arm64) TARGET="aarch64-unknown-linux-musl" ;;17+ *) echo "no Gleam build for $ARCH" >&2; exit 1 ;;18+esac19+20+TARBALL="gleam-v${GLEAM_VERSION}-${TARGET}.tar.gz"21+URL="https://github.com/gleam-lang/gleam/releases/download/v${GLEAM_VERSION}/${TARBALL}"22+23+mkdir -p .bin24+if [ ! -x .bin/gleam ]; then25+ echo "fetching Gleam ${GLEAM_VERSION} for ${TARGET}"26+ WORK="$(mktemp -d)"27+ curl -fsSL "$URL" -o "${WORK}/${TARBALL}"28+ curl -fsSL "${URL}.sha256" -o "${WORK}/${TARBALL}.sha256"29+ # The published digest already names the file it belongs to, so the check runs30+ # from the directory that file is in. A download nobody verified is a download31+ # anybody can replace.32+ ( cd "$WORK" && sha256sum -c "${TARBALL}.sha256" )33+ tar xzf "${WORK}/${TARBALL}" -C .bin34+ rm -rf "$WORK"35+fi36+37+export PATH="$PWD/.bin:$PATH"38+gleam --version39+gleam test40+gleam run -m lustre/dev build