-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (57 loc) · 2.09 KB
/
Copy pathMakefile
File metadata and controls
69 lines (57 loc) · 2.09 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
# Build container images locally using Podman
# Default registry and namespace
REGISTRY ?= quay.io
NAMESPACE ?= agentfox
# Image names and tags
OPENCODE_IMAGE = $(REGISTRY)/$(NAMESPACE)/opencode
TAG ?= latest
# Build tool
CONTAINER_TOOL ?= podman
# Build arguments
BUILD_ARGS ?= --build-arg TARGETARCH=$(shell uname -m | sed 's/x86_64/amd64/')
.PHONY: help all build-all opencode clean clean-all push-all
# Build the opencode image
opencode:
@echo "🔨 Building opencode image..."
$(CONTAINER_TOOL) build $(BUILD_ARGS) \
-f containers/opencode/Containerfile \
-t $(OPENCODE_IMAGE):$(TAG) \
containers/opencode/
@echo "✅ Opencode image built: $(OPENCODE_IMAGE):$(TAG)"
# run the opencode image
run:
@echo "🔨 Running opencode image..."
source .env && \
$(CONTAINER_TOOL) run -d \
--name opencode \
-p 4096:4096 \
-v ./data/data:/opt/app-root/data \
-v ./data/state:/opt/app-root/state \
-v ./data/config:/opt/app-root/config \
-v ./data/cache:/opt/app-root/cache \
-e TZ="${TZ}" \
-e OPENCODE_SERVER_USERNAME="${OPENCODE_SERVER_USERNAME}" \
-e OPENCODE_SERVER_PASSWORD="${OPENCODE_SERVER_PASSWORD}" \
$(OPENCODE_IMAGE):$(TAG)
@echo "✅ Opencode image running"
# Clean up any configuration files
clean-config:
@echo "🧹 Cleaning up configuration files..."
rm -rf data/data data/state data/config data/cache
@echo "✅ Configuration files cleaned"
create-config:
@echo "🧹 Creating configuration files..."
mkdir -p data/data/opencode data/state data/config/opencode data/cache
cp hack/auth.json ./data/data/opencode/auth.json
cp hack/opencode.jsonc ./data/config/opencode/opencode.jsonc
@echo "✅ Configuration files created"
# Clean up locally built images
clean-images:
@echo "🧹 Cleaning up locally built images..."
-$(CONTAINER_TOOL) rmi $(OPENCODE_IMAGE):$(TAG) 2>/dev/null || true
@echo "✅ Local images cleaned"
# Clean up all related images including base images and any configuration files
clean-all: clean-config clean-images
@echo "🧹 Cleaning up all related images..."
-$(CONTAINER_TOOL) system prune -f 2>/dev/null || true
@echo "✅ All images cleaned"