-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (66 loc) · 1.62 KB
/
Makefile
File metadata and controls
83 lines (66 loc) · 1.62 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
# Project variables
PROJECT_NAME = prompt-log
DOCKER_COMPOSE_FILE = docker-compose.yml
# Docker Compose commands
UP = docker-compose -f $(DOCKER_COMPOSE_FILE) up
UP_DETACHED = docker-compose -f $(DOCKER_COMPOSE_FILE) up -d
DOWN = docker-compose -f $(DOCKER_COMPOSE_FILE) down
BUILD = docker-compose -f $(DOCKER_COMPOSE_FILE) build
BUILD_NO_CACHE = docker-compose -f $(DOCKER_COMPOSE_FILE) build --no-cache
CLEAN = docker system prune -f
# Docker-compose workflows
# Default task
.PHONY: default
default: up
# Build images with cache
.PHONY: build
build:
$(BUILD)
# Build images without cache
.PHONY: no-cache
no-cache:
$(BUILD_NO_CACHE)
# Spin up the development environment
.PHONY: up
up:
$(UP)
# Spin up the development environment in detached mode
.PHONY: up-detached
up-detached:
$(UP_DETACHED)
# Stop all containers
.PHONY: down
down:
$(DOWN)
# Cleanup stale images
.PHONY: clean
clean:
$(CLEAN)
# Show logs for all services
.PHONY: logs
logs:
docker-compose -f $(DOCKER_COMPOSE_FILE) logs --follow
# Restart a service
.PHONY: restart
restart:
$(DOWN)
$(UP)
# Dev workflows
# Function to start service in a new terminal window
define run_in_new_window
osascript \
-e "tell application \"Terminal\"" \
-e "do script \"cd $(1) && $(2)\"" \
-e "end tell"
endef
# Start the API server
.PHONY: run-api-dev
run-api-dev:
$(call run_in_new_window,$(shell pwd)/prompt-log-api,make run-dev)
# Start the frontend server
.PHONY: run-app-dev
run-app-dev:
$(call run_in_new_window,$(shell pwd)/prompt-log-app,npm run dev)
# Start both API and frontend server
.PHONY: run-dev
run-dev: run-api-dev run-app-dev