about summary refs log tree commit diff stats
path: root/justfile
blob: aec4a36f84e3a1b98732aa0a378e7973a639470f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#! /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", `date +%Y%m%d%H%M%S` + "-" + `git rev-parse --short HEAD`)
environment := "production"
started-at := `date +%s`

default:
    @just --list --justfile {{ justfile() }} --unsorted

clean:
	rm -r website

check:
    nix flake check . --print-build-logs

check-licenses:
    nix run nixpkgs#go-licenses check ./...

check-links:
	hyperlink website/public

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 -w cmd/build -w content -w templates -r go run ./cmd/build --base-url http://localhost:3000")

build:
    go run ./cmd/build

nix-build what:
    nix build .#{{ what }}

watch-server: (watch-flake "watchexec -r -i content -i templates go run ./cmd/server")

dev:
	modd

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 inspect docker-archive:{{ image-path }}

print-docker-tag:
    @echo {{ fly-registry }}:{{ docker-tag }}

stream-to-registry :
    just docker-stream-fly | gzip --fast | skopeo copy --dest-precompute-digests docker-archive:/dev/stdin docker://{{ fly-registry }}:{{ docker-tag }}

push-to-registry:
    skopeo copy --dest-precompute-digests docker-archive://`readlink -f result`  docker://{{ fly-registry }}:{{ docker-tag }}

deploy-fly registry-and-tag=(fly-registry + ":" + docker-tag):
    fly deploy --image {{ registry-and-tag }}

deploy-vercel-preview: clean build
	vercel pull --environment=preview
	vercel deploy

deploy-vercel: clean build check-links
	vercel pull --environment=production
	vercel deploy --prod

deploy-netlify-preview: clean build
	netlify deploy

deploy-netlify: clean build check-links
	netlify deploy --prodIfUnlocked

deploy-production: deploy-vercel deploy-netlify