-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (73 loc) · 2.49 KB
/
Makefile
File metadata and controls
91 lines (73 loc) · 2.49 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
89
90
91
include .env
export
.PHONY: build up down shell logs format lint test clean prepare-remote-folder start-sync stop-sync status-sync connect disconnect
# Build the Docker image
build:
docker build -t $(IMAGE_NAME) .
build-no-cache:
docker-compose build --no-cache
# Initialize the Python project inside the container
init:
docker exec -it $(CONTAINER_NAME) uv pip sync --system pyproject.toml
docker exec -it $(CONTAINER_NAME) uv pip list
init-dev:
docker exec -it $(CONTAINER_NAME) uv pip sync --system 'pyproject.toml[dev]'
# Start the container and enable Mutagen sync
up: start-sync
docker-compose up -d
# Stop the container and Mutagen sync
down: stop-sync
docker-compose down
# Open an interactive shell inside the running container
shell:
docker exec -it $(CONTAINER_NAME) bash
# View container logs
logs:
docker logs -f $(CONTAINER_NAME)
# Run Black & Ruff formatting inside the container
format:
docker exec -it $(CONTAINER_NAME) black . && docker exec -it $(CONTAINER_NAME) ruff --fix .
# Run Ruff linting inside the container
lint:
docker exec -it $(CONTAINER_NAME) ruff check .
# Run tests inside the container
test:
docker exec -it $(CONTAINER_NAME) pytest
# Clean up all stopped containers, dangling images, and unused volumes
clean:
docker system prune -af
# Ensure the remote project directory exists with the correct permissions
prepare-remote-folder:
ssh $(REMOTE_HOST) "bash -c '\
if [ ! -d \"$(REMOTE_PROJECT_PATH)\" ]; then \
sudo mkdir -p \"$(REMOTE_PROJECT_PATH)\"; \
sudo chown $(APP_UID):$(APP_GID) \"$(REMOTE_PROJECT_PATH)\"; \
sudo chmod g+rwX \"$(REMOTE_PROJECT_PATH)\"; \
sudo chmod g+s \"$(REMOTE_PROJECT_PATH)\"; \
fi'"
# Start Mutagen sync (only if no session exists)
start-sync:
@if mutagen sync list | grep -q "$(CONTAINER_NAME)"; then \
echo "Mutagen sync already running for $(CONTAINER_NAME)"; \
else \
mutagen sync create \
--ignore-vcs \
--sync-mode=two-way-resolved \
--default-file-mode=0660 \
--default-directory-mode=0770 \
--default-group-beta=$(APP_GROUP) \
--name=$(CONTAINER_NAME) \
$(LOCAL_PROJECT_PATH) $(REMOTE_HOST):$(REMOTE_PROJECT_PATH); \
fi
# Stop Mutagen sync for this project only
stop-sync:
mutagen sync terminate $(CONTAINER_NAME)
# Check Mutagen sync status
status-sync:
mutagen sync list
# Start the container with the mounted workspace
connect: prepare-remote-folder start-sync
docker-compose up -d
# Disconnect by stopping the container and stopping sync
disconnect: stop-sync
docker-compose down