-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (71 loc) · 2.3 KB
/
Copy pathMakefile
File metadata and controls
81 lines (71 loc) · 2.3 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
# Dev Container Makefile
# Build and run AI-powered development container
# Use bash for recipe commands ($RANDOM is bash-specific)
SHELL := /bin/bash
IMAGE_NAME := dev-container
CONTAINER_NAME := dev-container
HOME_DIR := $(CURDIR)/home
PROJECT ?= $(CURDIR)
USER_UID := $(shell id -u)
USER_GID := $(shell id -g)
.PHONY: build run shell test init clean help
# Build the Docker image
build:
docker build \
--build-arg USER_UID=$(USER_UID) \
--build-arg USER_GID=$(USER_GID) \
-t $(IMAGE_NAME) .
# Run container with mounted volumes
# - ./home -> /home/developer (persistent home for credentials, configs)
# - PROJECT -> /workspace (project to work on)
run: init
docker run -it --rm \
--name $(CONTAINER_NAME)-$$(date +%s)-$$RANDOM \
-v "$(HOME_DIR):/home/developer" \
-v "$(PROJECT):/workspace" \
$(IMAGE_NAME)
# Start an interactive shell in the container
shell: init
docker run -it --rm \
--name $(CONTAINER_NAME)-shell-$$(date +%s)-$$RANDOM \
-v "$(HOME_DIR):/home/developer" \
-v "$(PROJECT):/workspace" \
$(IMAGE_NAME) \
/bin/bash
# Run smoke tests to verify all tools are installed
test: init
docker run --rm \
--name $(CONTAINER_NAME)-test-$$(date +%s)-$$RANDOM \
-v "$(HOME_DIR):/home/developer" \
-v "$(CURDIR):/workspace" \
$(IMAGE_NAME) \
/workspace/scripts/smoke-test.sh
# Initialize home directory if it doesn't exist
init:
@mkdir -p "$(HOME_DIR)"
@mkdir -p "$(HOME_DIR)/go"
@echo "Home directory ready: $(HOME_DIR)"
# Remove the Docker image
clean:
docker rmi $(IMAGE_NAME) 2>/dev/null || true
# Show help
help:
@echo "Dev Container Makefile"
@echo ""
@echo "Usage:"
@echo " make build - Build the Docker image"
@echo " make run - Run container (current dir as workspace)"
@echo " make shell - Start interactive shell in container"
@echo " make test - Run smoke tests"
@echo " make init - Create home directory if needed"
@echo " make clean - Remove the Docker image"
@echo ""
@echo "Variables:"
@echo " PROJECT=/path/to/project - Mount a different project as workspace"
@echo " USER_UID=$(USER_UID) - Container user UID (auto-detected)"
@echo " USER_GID=$(USER_GID) - Container user GID (auto-detected)"
@echo ""
@echo "Examples:"
@echo " make build"
@echo " make run"
@echo " make run PROJECT=/path/to/myproject"