-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (33 loc) · 1.73 KB
/
Copy pathMakefile
File metadata and controls
43 lines (33 loc) · 1.73 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
.PHONY: build build-latest run shell clean tag-latest build-builder-tools
USER_UID := $(shell id -u)
USER_GID := $(shell id -g)
VERSION ?=
COMMON_DOCKER_FLAGS := --rm -it --read-only --tmpfs /tmp:exec,size=512m --cap-drop=ALL --security-opt=no-new-privileges --memory=2g --cpus=2
COMMON_VOLUME_FLAGS := -v $(shell pwd)/homebase:/app:rw -v $(shell pwd)/config:/app/.config/opencode:rw -v $(shell pwd)/workspace:/workspace:rw -v $(shell pwd)/secrets:/run/secrets:ro
build:
docker build --build-arg USER_UID=$(USER_UID) --build-arg USER_GID=$(USER_GID) $(if $(VERSION),--build-arg OPENCODE_VERSION=$(VERSION),) -t opencode-docker$(if $(VERSION),:$(VERSION),) .
build-builder-tools:
docker build --build-arg USER_UID=$(USER_UID) --build-arg USER_GID=$(USER_GID) $(if $(VERSION),--build-arg OPENCODE_VERSION=$(VERSION),) --target builder-tools -t opencode-docker:builder-tools .
tag-latest:
ifndef VERSION
$(error VERSION is required. Usage: make tag-latest VERSION=1.3.17)
endif
docker tag opencode-docker:$(VERSION) opencode-docker:latest
build-latest:
@VERSION=$$(curl -s https://api.github.com/repos/anomalyco/opencode/releases/latest | jq -r '.tag_name' | sed 's/^v//') && \
echo "Building opencode-docker:$$VERSION..." && \
$(MAKE) build VERSION=$$VERSION && \
$(MAKE) tag-latest VERSION=$$VERSION
# Development targets: use local directories (./homebase, ./workspace, ./secrets)
# For regular use, prefer: bin/opencode-docker (uses ~/.opencode-docker/)
run:
docker run $(COMMON_DOCKER_FLAGS) \
$(COMMON_VOLUME_FLAGS) \
opencode-docker:latest /workspace
shell: build-builder-tools
docker run $(COMMON_DOCKER_FLAGS) \
$(COMMON_VOLUME_FLAGS) \
--entrypoint /bin/bash \
opencode-docker:builder-tools
clean:
docker rmi opencode-docker || true