about summary refs log tree commit diff stats
path: root/justfile
diff options
context:
space:
mode:
authorAlan Pearce2024-04-21 18:46:12 +0200
committerAlan Pearce2024-04-21 20:48:34 +0200
commitf334fc8d4caed2663ef3008f43d2f2fc48e3eaa9 (patch)
treef0942e920e8a2e4161f0a8dad3a15b9a7aff6d08 /justfile
parent2c6722bd18097cdcbed23d526ace0b751caf324a (diff)
downloadwebsite-f334fc8d4caed2663ef3008f43d2f2fc48e3eaa9.tar.lz
website-f334fc8d4caed2663ef3008f43d2f2fc48e3eaa9.tar.zst
website-f334fc8d4caed2663ef3008f43d2f2fc48e3eaa9.zip
use justfile for scripting
Diffstat (limited to 'justfile')
-rwxr-xr-xjustfile57
1 files changed, 57 insertions, 0 deletions
diff --git a/justfile b/justfile
new file mode 100755
index 0000000..3ebc592
--- /dev/null
+++ b/justfile
@@ -0,0 +1,57 @@
+#! /usr/bin/env -S nix develop . --command just --justfile
+
+fly-system := "x86_64-linux"
+fly-registry := "registry.fly.io/alanpearce-eu"
+docker-tag := env_var_or_default("DOCKER_TAG", `git rev-parse HEAD`)
+
+default:
+    @just --list --justfile {{ justfile() }} --unsorted
+
+check:
+    nix flake check . --print-build-logs
+
+check-licenses:
+    nix run nixpkgs#go-licenses
+
+update-all:
+    go get -u all
+    gomod2nix --outdir nix
+    nix flake update
+
+watch-flake command:
+    watchexec --restart -w flake.nix -w flake.lock direnv exec . {{ command }}
+
+watch-builder: (watch-flake "watchexec -i cmd/server -i public -r go run ./cmd/build")
+
+nix-build what:
+    nix build .#{{ what }}
+
+watch-server: (watch-flake "watchexec -r go run ./cmd/server")
+
+docker-stream system=(arch() + "-linux"):
+    @nix build --print-out-paths .#docker-stream-{{ system }} | sh
+
+docker-image system=(arch() + "-linux"):
+    nix build .#docker-image-{{ system }}
+
+docker-stream-fly:
+    just docker-stream fly-system
+
+docker-image-fly: (docker-image fly-system)
+
+docker-inspect image-path="result" *skopeo-flags="":
+    skopeo {{ skopeo-flags }} inspect docker-archive:{{ image-path }}
+
+print-docker-tag:
+    @echo {{ docker-tag }}
+
+# docker://some_docker_registry/myimage:tag
+stream-to-registry registry-and-tag=(fly-registry + ":" + docker-tag) *skopeo-flags="":
+    just docker-stream-fly | gzip --fast | skopeo {{ skopeo-flags }} copy docker-archive:/dev/stdin {{ registry-and-tag }}
+
+# docker://some_docker_registry/myimage:tag
+push-to-registry registry-and-tag=(fly-registry + ":" + docker-tag) image-path=`readlink -f result` *skopeo-flags="":
+    skopeo {{ skopeo-flags }} copy {{ registry-and-tag }} {{ registry-and-tag }}
+
+deploy registry-and-tag=(fly-registry + ":" + docker-tag):
+    fly deploy --image {{ registry-and-tag }}