-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (92 loc) · 2.94 KB
/
Copy pathMakefile
File metadata and controls
117 lines (92 loc) · 2.94 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.PHONY: deps compile test test.all format format.check \
build run stop logs \
docker.buildx docker.build docker.push docker.publish docker.publish.fresh docker.publish.local \
tag release clean
IMAGE := iksnerd/code-nexus
VERSION := $(shell cat VERSION)
TAG := v$(VERSION)
PLATFORMS := linux/arm64
BUILDER := desktop-linux
## Development
deps:
mix deps.get
compile: deps
mix compile --warnings-as-errors
test: compile
mix test --exclude performance --exclude multi_project --exclude nif --exclude file_watcher
test.all: compile
mix test
format:
mix format
format.check:
mix format --check-formatted
## Docker (local single-arch via docker-compose)
build:
docker-compose build code_nexus
run:
WORKSPACE=~/www docker-compose up -d
stop:
docker-compose down
logs:
docker logs -f code_nexus
## Docker Hub publish (arm64 via desktop-linux builder)
# desktop-linux is the built-in Docker Desktop builder — always present, no setup needed.
docker.buildx:
@docker buildx inspect $(BUILDER) >/dev/null 2>&1
# Build multi-arch image locally without pushing (verifies the build).
docker.build: docker.buildx
docker buildx build \
--platform $(PLATFORMS) \
-t $(IMAGE):$(TAG) \
-t $(IMAGE):latest \
.
# Build and push multi-arch image to Docker Hub.
# This is the main release command — replaces the old CI publish job.
docker.publish: docker.buildx
@echo "Publishing $(IMAGE):$(TAG) and :latest for $(PLATFORMS)"
docker buildx build \
--platform $(PLATFORMS) \
-t $(IMAGE):$(TAG) \
-t $(IMAGE):latest \
--push \
.
# Full rebuild from scratch — use after Dockerfile, .dockerignore, or .agents/ changes.
docker.publish.fresh: docker.buildx
@echo "Publishing $(IMAGE):$(TAG) and :latest (--no-cache) for $(PLATFORMS)"
docker buildx build \
--no-cache \
--platform $(PLATFORMS) \
-t $(IMAGE):$(TAG) \
-t $(IMAGE):latest \
--push \
.
# Local-only single-arch build for fast iteration (host platform).
docker.publish.local:
docker build -t $(IMAGE):$(TAG) -t $(IMAGE):latest .
## Release
# Bump version in mix.exs first, then run `make release`.
# This runs the pre-push checks, tags the commit, pushes the tag,
# and publishes a multi-arch image to Docker Hub.
release: format.check test
@echo "Tagging $(TAG)..."
@git tag -a $(TAG) -m "Release $(TAG)" 2>/dev/null || echo "Tag $(TAG) already exists"
@git push origin $(TAG)
$(MAKE) docker.publish
@echo "Released $(TAG) — image pushed to Docker Hub"
# Just create + push a tag (no docker build).
tag:
@echo "Current version in mix.exs: $(VERSION)"
@echo "Tagging $(TAG)..."
git tag -a $(TAG) -m "Release $(TAG)"
git push origin $(TAG)
## Cleanup
clean:
mix clean
rm -rf _build deps
# Remove old image tags from local Docker, keeping only :latest and current $(TAG).
clean.images:
@echo "Keeping $(IMAGE):latest and $(IMAGE):$(TAG)"
@docker images --format '{{.Repository}}:{{.Tag}}' | \
grep '^$(IMAGE):v' | \
grep -v '^$(IMAGE):$(TAG)$$' | \
xargs -r docker rmi || true