| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 1 | # Makefile for building sketch with embedded assets |
| 2 | # |
| 3 | # Two-layer architecture: |
| 4 | # 1. Linux binary ("innie") - runs in container, embeds webui assets |
| 5 | # 2. Native binary ("outie") - runs on user's machine, embeds innie |
| 6 | |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 7 | # Allow overriding some env vars, used by GoReleaser |
| 8 | BUILT_BY ?= make |
| 9 | SKETCH_VERSION ?= |
| Josh Bleecher Snyder | 973413b | 2025-07-08 19:35:05 +0000 | [diff] [blame] | 10 | GOOS ?= $(shell go env GOOS) |
| 11 | GOARCH ?= $(shell go env GOARCH) |
| 12 | |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 13 | export BUILT_BY |
| 14 | export SKETCH_VERSION |
| 15 | export GOOS |
| 16 | export GOARCH |
| 17 | export LDFLAGS := -X main.builtBy=$(BUILT_BY) -X main.release=$(SKETCH_VERSION) |
| 18 | |
| 19 | .PHONY: all clean outie innie webui |
| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 20 | |
| 21 | all: outie |
| 22 | |
| 23 | outie: innie |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 24 | ./build/outie.sh |
| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 25 | |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 26 | innie: webui |
| 27 | ./build/innie.sh |
| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 28 | |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 29 | webui: |
| 30 | ./build/webui.sh |
| Josh Bleecher Snyder | 1c18ec9 | 2025-07-08 10:55:54 -0700 | [diff] [blame] | 31 | |
| 32 | clean: |
| Josh Bleecher Snyder | 6ae637a | 2025-07-09 12:41:56 -0700 | [diff] [blame] | 33 | ./build/clean.sh |
| Giorgi Lekveishvili | 3d0067f | 2025-06-20 06:12:46 +0400 | [diff] [blame] | 34 | |
| 35 | |
| 36 | |
| 37 | # DODO |
| 38 | |
| 39 | repo_name ?= giolekva |
| 40 | podman ?= docker |
| 41 | docker_flags=--provenance=false --sbom=false |
| 42 | ifeq ($(podman), podman) |
| 43 | manifest_dest=docker://docker.io/$(repo_name)/sketch:latest |
| 44 | endif |
| 45 | |
| Sketch🕴️ | 9988c51 | 2025-07-31 16:45:04 +0400 | [diff] [blame] | 46 | # clean: |
| 47 | # rm -f sketch |
| Giorgi Lekveishvili | 3d0067f | 2025-06-20 06:12:46 +0400 | [diff] [blame] | 48 | |
| 49 | build_arm64: export CGO_ENABLED=0 |
| 50 | build_arm64: export GO111MODULE=on |
| 51 | build_arm64: export GOOS=linux |
| 52 | build_arm64: export GOARCH=arm64 |
| 53 | build_arm64: |
| Sketch🕴️ | 9988c51 | 2025-07-31 16:45:04 +0400 | [diff] [blame] | 54 | make |
| 55 | cp sketch sketch_arm64 |
| Giorgi Lekveishvili | 3d0067f | 2025-06-20 06:12:46 +0400 | [diff] [blame] | 56 | |
| 57 | build_amd64: export CGO_ENABLED=0 |
| 58 | build_amd64: export GO111MODULE=on |
| 59 | build_amd64: export GOOS=linux |
| 60 | build_amd64: export GOARCH=amd64 |
| 61 | build_amd64: |
| Sketch🕴️ | 9988c51 | 2025-07-31 16:45:04 +0400 | [diff] [blame] | 62 | make |
| 63 | cp sketch sketch_amd64 |
| Giorgi Lekveishvili | 3d0067f | 2025-06-20 06:12:46 +0400 | [diff] [blame] | 64 | |
| 65 | push_arm64: clean build_arm64 |
| 66 | $(podman) build --platform linux/arm64 --tag=$(repo_name)/sketch:arm64 $(docker_flags) . |
| 67 | $(podman) push $(repo_name)/sketch:arm64 |
| 68 | |
| 69 | push_amd64: clean build_amd64 |
| 70 | $(podman) build --platform linux/amd64 --tag=$(repo_name)/sketch:amd64 $(docker_flags) . |
| 71 | $(podman) push $(repo_name)/sketch:amd64 |
| 72 | |
| 73 | push: push_arm64 push_amd64 |
| 74 | $(podman) manifest create $(repo_name)/sketch:latest $(repo_name)/sketch:arm64 $(repo_name)/sketch:amd64 |
| 75 | $(podman) manifest push --purge $(repo_name)/sketch:latest $(manifest_dest) |