diff --git a/.gitignore b/.gitignore index 900c5a4..9feef86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.s9pk image.tar +docker-images/ scripts/embassy.js .DS_Store diff --git a/Makefile b/Makefile index bd0bae5..80d3c95 100644 --- a/Makefile +++ b/Makefile @@ -3,33 +3,77 @@ PKG_VERSION := $(shell yq -r .version manifest.yaml) TS_FILES := $(shell find ./scripts -name \*.ts 2>/dev/null) +# Where KamadoPool source lives (buildx passes it as a named context). +KAMADO_SRC ?= ../KamadoPool + .DELETE_ON_ERROR: +# Default: build both arches and verify a universal package. all: verify +# Single-arch convenience targets — much faster if you don't have +# qemu-user-static registered for cross-arch emulation. +x86: ARCH = x86_64 +x86: + @rm -f docker-images/aarch64.tar + $(MAKE) ARCH=x86_64 + +arm: ARCH = aarch64 +arm: + @rm -f docker-images/x86_64.tar + $(MAKE) ARCH=aarch64 + verify: $(PKG_ID).s9pk start-sdk verify s9pk $(PKG_ID).s9pk + @echo "Package: $(PKG_ID).s9pk ($(shell du -h $(PKG_ID).s9pk | cut -f1))" install: $(PKG_ID).s9pk start-cli package install $(PKG_ID).s9pk -$(PKG_ID).s9pk: manifest.yaml instructions.md icon.png LICENSE scripts/embassy.js image.tar - start-sdk pack - +# ── TypeScript → JS bundle ─────────────────────────────────────────── scripts/embassy.js: $(TS_FILES) deno run --allow-read --allow-write --allow-env --allow-net scripts/bundle.ts -KAMADO_SRC ?= ../KamadoPool -PLATFORMS ?= linux/arm64/v8,linux/amd64 - -image.tar: Dockerfile docker_entrypoint.sh - docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \ - --platform=$(PLATFORMS) \ - --build-arg ARCH=$(shell uname -m) \ +# ── Docker images, one tarball per arch ────────────────────────────── +docker-images/x86_64.tar: Dockerfile docker_entrypoint.sh +ifneq ($(ARCH),aarch64) + mkdir -p docker-images + docker buildx build \ + --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \ + --platform linux/amd64 \ + --build-arg ARCH=x86_64 \ --build-context kamado=$(KAMADO_SRC) \ - -o type=oci,dest=image.tar . + -o type=docker,dest=docker-images/x86_64.tar \ + . +endif + +docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh +ifneq ($(ARCH),x86_64) + mkdir -p docker-images + docker buildx build \ + --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \ + --platform linux/arm64 \ + --build-arg ARCH=aarch64 \ + --build-context kamado=$(KAMADO_SRC) \ + -o type=docker,dest=docker-images/aarch64.tar \ + . +endif + +# ── Pack ───────────────────────────────────────────────────────────── +$(PKG_ID).s9pk: manifest.yaml instructions.md icon.png LICENSE \ + scripts/embassy.js \ + docker-images/x86_64.tar docker-images/aarch64.tar +ifeq ($(ARCH),x86_64) + @echo "start-sdk: packing x86_64 only" +else ifeq ($(ARCH),aarch64) + @echo "start-sdk: packing aarch64 only" +else + @echo "start-sdk: packing universal (x86_64 + aarch64)" +endif + start-sdk pack clean: + rm -rf docker-images rm -f $(PKG_ID).s9pk image.tar scripts/embassy.js -.PHONY: all verify install clean +.PHONY: all x86 arm verify install clean diff --git a/manifest.yaml b/manifest.yaml index ecdbd8a..25a00a8 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -31,7 +31,6 @@ assets: license: LICENSE icon: icon.png instructions: instructions.md - docker-images: image.tar main: type: docker