-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (70 loc) · 2.21 KB
/
Makefile
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
# Determine the operating system
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
DEFAULT_CACHE_DIR := $(shell powershell -Command "Join-Path $$env:USERPROFILE '.github-action-cache'")
CHECK_CACHE_DIR := powershell -Command "if (Test-Path .env) { $$env = Get-Content .env -Raw | ConvertFrom-StringData; if ($$env.DOCKER_CACHE_DIR) { Write-Output $$env.DOCKER_CACHE_DIR } }"
SETUP_SCRIPT := powershell -ExecutionPolicy Bypass -File etc/setup-cache-dir.ps1
else
DETECTED_OS := $(shell uname -s)
DEFAULT_CACHE_DIR := $(HOME)/.github-action-cache
CHECK_CACHE_DIR := if [ -f .env ] && grep -q DOCKER_CACHE_DIR .env; then grep DOCKER_CACHE_DIR .env | cut -d '=' -f2; fi
SETUP_SCRIPT := bash etc/setup-cache-dir.sh
endif
# Docker image name and tag
IMAGE_NAME := tensorpod/actions-image
IMAGE_TAG := latest
.PHONY: setup
setup:
@echo "Setting up GitHub Actions cache directory..."
@$(SETUP_SCRIPT)
@python3 ./etc/set-registry-as-insecure.py || python ./etc/set-registry-as-insecure.py
# Function to load .env and export variables
.PHONY: load_env
load_env:
@echo "Loading environment variables..."
$(eval include .env)
$(eval export)
.PHONY: build
build: setup load_env
@echo "Building Docker image..."
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) -f docker/Dockerfile.dood . --build-arg DOCKER_CACHE_DIR=$(DOCKER_CACHE_DIR)
.PHONY: up
up:
docker-compose up -d
.PHONY: down
down:
@echo "Stopping and removing containers..."
docker-compose down
.PHONY: logs
logs:
docker-compose logs -f
.PHONY: clean
clean:
docker-compose down -v
rm -f .env
.PHONY: test-daemon
test: setup
@echo "Testing DOOD daemon access..."
@docker run --rm \
--entrypoint /test_docker_daemon_access.sh \
$(IMAGE_NAME):$(IMAGE_TAG)
.PHONY: test-buildx
test-buildx:
@echo "Testing Docker Buildx setup..."
@docker run --rm \
--entrypoint /test_buildx.sh \
$(IMAGE_NAME):$(IMAGE_TAG)
.PHONY: test-registry
test-registry: setup
@echo "Testing registry access..."
@docker-compose run --rm \
--entrypoint /bin/bash \
runner \
-c "/test_registry_access.sh"
.PHONY: test-mongodb
test-mongodb: setup
@echo "Testing MongoDB access..."
@docker-compose run --rm \
--entrypoint /bin/bash \
runner \
-c "python3 test_mongodb.py"