forked from Zeeno-atl/claude-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (77 loc) · 2.82 KB
/
Makefile
File metadata and controls
88 lines (77 loc) · 2.82 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
# Claude Code Container
# Makefile for building and managing the Claude Code Docker container
# Variables
IMAGE_NAME := claude-code
CONTAINER_NAME := claude-code-instance
NPM_CACHE_VOLUME := claude-code-npm-cache
# Default target
.PHONY: all
all: build ## Build the Docker image (default target)
# Build the Docker image
.PHONY: build
build: ## Build the Docker image without using cache (ensures fresh npm packages)
@echo "Building Docker image $(IMAGE_NAME) without cache..."
docker build --no-cache --pull -t $(IMAGE_NAME) .
@echo "Build complete."
# Quick build (with cache for faster rebuilds)
.PHONY: quick-build
quick-build: ## Build the Docker image using cache for faster rebuilds
@echo "Building Docker image $(IMAGE_NAME) with cache..."
docker build --pull -t $(IMAGE_NAME) .
@echo "Quick build complete."
# Run the container
.PHONY: run
run: ## Run the Docker container with current directory mapped to /app
@echo "Starting container $(CONTAINER_NAME)..."
docker run --name $(CONTAINER_NAME) -it --rm \
-v "$$(pwd):/app" \
-v $(NPM_CACHE_VOLUME):/npm-cache \
-e CONTAINER_USER_ID=$$(id -u) \
-e CONTAINER_GROUP_ID=$$(id -g) \
$(IMAGE_NAME)
# Run with a specified directory
.PHONY: run-dir
run-dir: ## Run with a specified directory mapped to /app (usage: make run-dir DIR=/path/to/directory)
@if [ -z "$(DIR)" ]; then \
echo "Error: DIR parameter is required. Usage: make run-dir DIR=/path/to/directory"; \
exit 1; \
fi
@echo "Starting container $(CONTAINER_NAME) with $(DIR) mapped to /app..."
docker run --name $(CONTAINER_NAME) -it --rm \
-v "$(DIR):/app" \
-v $(NPM_CACHE_VOLUME):/npm-cache \
-e CONTAINER_USER_ID=$$(id -u) \
-e CONTAINER_GROUP_ID=$$(id -g) \
$(IMAGE_NAME)
# Run with API key
.PHONY: run-auth
run-auth: ## Run with Anthropic API key (usage: make run-auth KEY=your_api_key)
@if [ -z "$(KEY)" ]; then \
echo "Error: KEY parameter is required. Usage: make run-auth KEY=your_api_key"; \
exit 1; \
fi
@echo "Starting container $(CONTAINER_NAME) with API authentication..."
docker run --name $(CONTAINER_NAME) -it --rm \
-v "$$(pwd):/app" \
-v $(NPM_CACHE_VOLUME):/npm-cache \
-e ANTHROPIC_API_KEY="$(KEY)" \
-e CONTAINER_USER_ID=$$(id -u) \
-e CONTAINER_GROUP_ID=$$(id -g) \
$(IMAGE_NAME)
# Clean up resources
.PHONY: clean
clean: ## Remove the Docker image
@echo "Cleaning up resources..."
docker rmi $(IMAGE_NAME) || true
# Clean up everything including volumes
.PHONY: clean-all
clean-all: clean ## Remove the Docker image and all volumes
@echo "Removing npm cache volume..."
docker volume rm $(NPM_CACHE_VOLUME) || true
# Help command
.PHONY: help
help: ## Display this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'