mykiwi/mykiwi.blogpublic Fork 0
47c5f42
Commits
Clone
git clone https://git.rickub.com/mykiwi/mykiwi.blog.git
git clone ssh://git@rickub.com/mykiwi/mykiwi.blog.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Parallelize make deploy across languages

Split the deploy Nix app into a per-language invocation and let Make
fan the five Cloudflare Pages pushes out in parallel via a
--output-sync=target sub-make, instead of deploying them one at a time.
Romain Gautier committed 2026-09-18T21:56:25+02:00 Browse files
47c5f42 parent: 51380a7
modified Makefile +10 -2
@@ -7,6 +7,11 @@ include .env
77 export
88 endif
99
10+LANGS := en fr pt ja es
11+
12+# deploy-% targets aren't listed here: giving an instantiated pattern target
13+# (e.g. deploy-en) to .PHONY creates an explicit no-recipe rule for it, which
14+# then blocks the deploy-% pattern rule below from ever supplying a recipe.
1015 .PHONY: help dev build serve infra-plan infra-apply deploy clean
1116
1217 help:
@@ -27,8 +32,11 @@ infra-plan: ## Show what infra-apply would change on Cloudflare
2732 infra-apply: ## Apply infra/ changes to Cloudflare
2833 nix run .#infra -- apply
2934
30-deploy: ## Build the site and push it to Cloudflare Pages (all languages)
31- nix run .#deploy
35+deploy: build ## Build the site and push it to Cloudflare Pages (all languages, in parallel)
36+ $(MAKE) --no-print-directory --output-sync=target -j$(words $(LANGS)) $(addprefix deploy-,$(LANGS))
37+
38+deploy-%: ## Deploy a single language to Cloudflare Pages, e.g. `make deploy-en` (assumes `make build` already ran)
39+ nix run .#deploy -- $*
3240
3341 clean: ## Remove build outputs
3442 rm -rf result blog/public blog/resources
@@ -7,6 +7,11 @@ include .env
7 export7 export
8 endif8 endif
9 9
10+LANGS := en fr pt ja es
11+
12+# deploy-% targets aren't listed here: giving an instantiated pattern target
13+# (e.g. deploy-en) to .PHONY creates an explicit no-recipe rule for it, which
14+# then blocks the deploy-% pattern rule below from ever supplying a recipe.
10 .PHONY: help dev build serve infra-plan infra-apply deploy clean15 .PHONY: help dev build serve infra-plan infra-apply deploy clean
11 16
12 help:17 help:
@@ -27,8 +32,11 @@ infra-plan: ## Show what infra-apply would change on Cloudflare
27 infra-apply: ## Apply infra/ changes to Cloudflare32 infra-apply: ## Apply infra/ changes to Cloudflare
28 nix run .#infra -- apply33 nix run .#infra -- apply
29 34
30-deploy: ## Build the site and push it to Cloudflare Pages (all languages)35+deploy: build ## Build the site and push it to Cloudflare Pages (all languages, in parallel)
31- nix run .#deploy36+ $(MAKE) --no-print-directory --output-sync=target -j$(words $(LANGS)) $(addprefix deploy-,$(LANGS))
37+
38+deploy-%: ## Deploy a single language to Cloudflare Pages, e.g. `make deploy-en` (assumes `make build` already ran)
39+ nix run .#deploy -- $*
32 40
33 clean: ## Remove build outputs41 clean: ## Remove build outputs
34 rm -rf result blog/public blog/resources42 rm -rf result blog/public blog/resources
modified flake.nix +10 -12
@@ -77,24 +77,22 @@
7777 }}/bin/mykiwi-blog-infra";
7878 };
7979
80- # `nix run .#deploy` - builds the site (the same `packages.default`
81- # derivation `nix build` uses) and pushes each language's output
82- # folder to its matching Cloudflare Pages project. Needs
83- # CLOUDFLARE_API_TOKEN, same as `infra`.
80+ # `nix run .#deploy -- <lang>` - pushes the already-built `./result/<lang>`
81+ # folder (built separately via `make build` / `nix build`, the same
82+ # `packages.default` derivation) to its matching Cloudflare Pages
83+ # project. Needs CLOUDFLARE_API_TOKEN, same as `infra`. Takes a single
84+ # language so the Makefile can fan out `make deploy` across languages
85+ # in parallel via `make -j`.
8486 deploy = {
8587 type = "app";
8688 program = "${pkgs.writeShellApplication {
8789 name = "mykiwi-blog-deploy";
88- runtimeInputs = [ wrangler pkgs.git pkgs.nix ];
90+ runtimeInputs = [ wrangler pkgs.git ];
8991 text = ''
92+ lang="''${1:?usage: nix run .#deploy -- <lang>}"
9093 root="$(git rev-parse --show-toplevel)"
91- link="$(mktemp -d)/result"
92- nix build "$root#default" --out-link "$link"
93- for lang in en fr pt ja es; do
94- project="mykiwi-blog-$lang"
95- echo "==> deploying $lang -> $project"
96- wrangler pages deploy "$link/$lang" --project-name="$project" --branch=main
97- done
94+ project="mykiwi-blog-$lang"
95+ wrangler pages deploy "$root/result/$lang" --project-name="$project" --branch=main
9896 '';
9997 }}/bin/mykiwi-blog-deploy";
10098 };
@@ -77,24 +77,22 @@
77 }}/bin/mykiwi-blog-infra";77 }}/bin/mykiwi-blog-infra";
78 };78 };
79 79
80- # `nix run .#deploy` - builds the site (the same `packages.default`80+ # `nix run .#deploy -- <lang>` - pushes the already-built `./result/<lang>`
81- # derivation `nix build` uses) and pushes each language's output81+ # folder (built separately via `make build` / `nix build`, the same
82- # folder to its matching Cloudflare Pages project. Needs82+ # `packages.default` derivation) to its matching Cloudflare Pages
83- # CLOUDFLARE_API_TOKEN, same as `infra`.83+ # project. Needs CLOUDFLARE_API_TOKEN, same as `infra`. Takes a single
84+ # language so the Makefile can fan out `make deploy` across languages
85+ # in parallel via `make -j`.
84 deploy = {86 deploy = {
85 type = "app";87 type = "app";
86 program = "${pkgs.writeShellApplication {88 program = "${pkgs.writeShellApplication {
87 name = "mykiwi-blog-deploy";89 name = "mykiwi-blog-deploy";
88- runtimeInputs = [ wrangler pkgs.git pkgs.nix ];90+ runtimeInputs = [ wrangler pkgs.git ];
89 text = ''91 text = ''
92+ lang="''${1:?usage: nix run .#deploy -- <lang>}"
90 root="$(git rev-parse --show-toplevel)"93 root="$(git rev-parse --show-toplevel)"
91- link="$(mktemp -d)/result"94+ project="mykiwi-blog-$lang"
92- nix build "$root#default" --out-link "$link"95+ wrangler pages deploy "$root/result/$lang" --project-name="$project" --branch=main
93- for lang in en fr pt ja es; do
94- project="mykiwi-blog-$lang"
95- echo "==> deploying $lang -> $project"
96- wrangler pages deploy "$link/$lang" --project-name="$project" --branch=main
97- done
98 '';96 '';
99 }}/bin/mykiwi-blog-deploy";97 }}/bin/mykiwi-blog-deploy";
100 };98 };