-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (76 loc) · 2.89 KB
/
Makefile
File metadata and controls
87 lines (76 loc) · 2.89 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
.PHONY: help build run dev stop clean rebuild test
# Default target
help:
@echo "SPAC Docker Management"
@echo "======================"
@echo ""
@echo "Production targets:"
@echo " make build - Build production Docker image"
@echo " make run - Run production container with Jupyter"
@echo " make test - Run tests in production container"
@echo ""
@echo "Development targets:"
@echo " make dev - Start development environment with live code mounting"
@echo " make dev-bash - Start development container with bash shell"
@echo " make dev-test - Run tests in development mode"
@echo ""
@echo "Utility targets:"
@echo " make stop - Stop all running containers"
@echo " make clean - Remove containers and images"
@echo " make rebuild - Clean and rebuild production image"
@echo " make logs - Show container logs"
# Production build
build:
@echo "Building production Docker image..."
docker build -t spac:latest .
# Run production container
run:
@echo "Starting production container with Jupyter..."
docker run -d \
--name spac-prod \
-p 8888:8888 \
-v $(PWD)/data:/data \
-v $(PWD)/results:/results \
spac:latest
@echo "Jupyter available at http://localhost:8888"
# Development environment with live code mounting
dev:
@echo "Starting development environment with live code mounting..."
docker-compose -f docker/docker-compose.dev.yml up -d
@echo "Development Jupyter available at http://localhost:8889"
@echo "Source code is mounted - changes will be reflected immediately!"
# Development with bash shell
dev-bash:
@echo "Starting development container with bash shell..."
docker-compose -f docker/docker-compose.dev.yml run --rm --service-ports spac-dev bash
# Run tests in development mode
dev-test:
@echo "Running tests in development mode..."
docker-compose -f docker/docker-compose.dev.yml run --rm spac-dev \
/opt/conda/envs/spac/bin/pytest tests/ -v
# Run tests in production container
test:
@echo "Running tests in production container..."
docker run --rm spac:latest \
/opt/conda/envs/spac/bin/pytest tests/ -v
# Stop all containers
stop:
@echo "Stopping containers..."
-docker stop spac-prod 2>/dev/null || true
-docker-compose -f docker/docker-compose.dev.yml down 2>/dev/null || true
# Clean up containers and images
clean: stop
@echo "Cleaning up containers and images..."
-docker rm spac-prod 2>/dev/null || true
-docker rmi spac:latest 2>/dev/null || true
-docker-compose -f docker/docker-compose.dev.yml down -v 2>/dev/null || true
# Rebuild from scratch
rebuild: clean build
@echo "Rebuild complete!"
# Show logs
logs:
@echo "=== Production logs ==="
-docker logs spac-prod 2>/dev/null || echo "No production container running"
@echo ""
@echo "=== Development logs ==="
-docker-compose -f docker/docker-compose.dev.yml logs 2>/dev/null || echo "No development container running"