|
3 | 3 | COMPOSE ?= docker compose |
4 | 4 | FRONTEND_DIR := frontend |
5 | 5 | PYTHON ?= python3 |
| 6 | +FRONTEND_IMAGE_LOCAL := local/global-tsunami-risk-map-frontend:latest |
| 7 | +FRONTEND_IMAGE_REMOTE := ghcr.io/yejiyang/global-tsunami-risk-map-frontend:latest |
6 | 8 |
|
7 | | -.PHONY: help docker-build docker-up docker-down docker-logs docker-clean docker-rebuild-frontend docker-up-frontend docker-up-backend docker-rebuild-backend frontend-build frontend-serve docker-build-frontend docker-run-local docker-run |
| 9 | +.PHONY: help docker-build docker-up docker-down docker-logs docker-clean \ |
| 10 | + docker-up-% docker-rebuild-% frontend-build frontend-serve \ |
| 11 | + docker-build-frontend docker-run-local docker-run |
8 | 12 |
|
9 | 13 | .DEFAULT_GOAL := help |
10 | 14 |
|
11 | | -help: |
12 | | - @echo "Geospatial Dataset Publishing Project" |
13 | | - @echo "" |
14 | | - @echo "Docker Commands:" |
15 | | - @echo " docker-build - Build all Docker images" |
16 | | - @echo " docker-up - Start all Docker containers" |
17 | | - @echo " docker-down - Stop all Docker containers" |
18 | | - @echo " docker-logs - View Docker container logs" |
19 | | - @echo " docker-clean - Remove Docker containers, images, and volumes" |
20 | | - @echo " docker-rebuild-backend - Rebuild backend container (no cache)" |
21 | | - @echo " docker-rebuild-frontend - Rebuild frontend container (no cache)" |
22 | | - @echo " docker-up-frontend - Start only the frontend container" |
23 | | - @echo " docker-up-backend - Start only the backend container" |
24 | | - @echo " docker-build-frontend - Build local frontend Docker image" |
25 | | - @echo " docker-run-local - Run with locally built frontend image" |
26 | | - @echo " docker-run - Run with remote frontend image from GitHub" |
27 | | - @echo "" |
28 | | - @echo "Frontend Commands:" |
29 | | - @echo " frontend-build - Build frontend assets" |
30 | | - @echo " frontend-serve - Build and serve frontend locally" |
| 15 | +help: ## Show this help |
| 16 | + @grep -E '^[-a-zA-Z0-9_%]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ |
| 17 | + awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' |
31 | 18 |
|
32 | 19 |
|
33 | 20 | # Docker commands |
34 | | -docker-build: |
| 21 | +docker-build: ## Build all Docker images |
35 | 22 | @echo "Building Docker images..." |
36 | 23 | $(COMPOSE) build |
37 | 24 |
|
38 | | -docker-up: |
| 25 | +docker-up: ## Start all Docker containers |
39 | 26 | @echo "Starting Docker containers..." |
40 | 27 | $(COMPOSE) up -d |
41 | 28 |
|
42 | | -docker-down: |
| 29 | +docker-down: ## Stop all Docker containers |
43 | 30 | @echo "Stopping Docker containers..." |
44 | 31 | $(COMPOSE) down |
45 | 32 |
|
46 | | -docker-logs: |
| 33 | +docker-logs: ## View Docker container logs |
47 | 34 | @echo "Viewing Docker logs..." |
48 | 35 | $(COMPOSE) logs -f |
49 | 36 |
|
50 | | -docker-clean: |
| 37 | +docker-clean: ## Remove Docker containers, images, and volumes |
51 | 38 | @echo "Cleaning Docker resources..." |
52 | 39 | $(COMPOSE) down --rmi all --volumes --remove-orphans |
53 | 40 |
|
54 | | -docker-rebuild-frontend: |
55 | | - @echo "Rebuilding frontend Docker container..." |
56 | | - $(COMPOSE) build --no-cache frontend |
| 41 | +# Service-specific commands |
| 42 | +docker-rebuild-%: ## Rebuild a specific service without cache |
| 43 | + @echo "Rebuilding $* Docker container (no cache)..." |
| 44 | + $(COMPOSE) build --no-cache $* |
57 | 45 |
|
58 | | -docker-up-frontend: |
59 | | - @echo "Starting frontend Docker container..." |
60 | | - $(COMPOSE) up -d frontend |
61 | | - |
62 | | -docker-up-backend: |
63 | | - @echo "Starting backend Docker container..." |
64 | | - $(COMPOSE) up -d backend |
65 | | - |
66 | | -# Docker backend-specific commands |
67 | | -docker-rebuild-backend: |
68 | | - @echo "Rebuilding backend Docker container (no cache)..." |
69 | | - $(COMPOSE) build --no-cache backend |
| 46 | +docker-up-%: ## Start a specific service |
| 47 | + @echo "Starting $* Docker container..." |
| 48 | + $(COMPOSE) up -d $* |
70 | 49 |
|
71 | 50 | # Build and run with local or remote frontend image |
72 | | -docker-build-frontend: |
| 51 | +docker-build-frontend: ## Build local frontend Docker image |
73 | 52 | @echo "Building local frontend Docker image..." |
74 | | - docker build -t local/global-tsunami-risk-map-frontend:latest ./$(FRONTEND_DIR) |
| 53 | + docker build -t $(FRONTEND_IMAGE_LOCAL) ./$(FRONTEND_DIR) |
75 | 54 |
|
76 | | -docker-run-local: docker-build-frontend |
| 55 | +docker-run-local: docker-build-frontend ## Run with locally built frontend image |
77 | 56 | @echo "Running with local frontend image..." |
78 | | - USE_LOCAL_BUILD=local/global-tsunami-risk-map-frontend $(COMPOSE) up -d |
| 57 | + USE_LOCAL_BUILD=$(FRONTEND_IMAGE_LOCAL) $(COMPOSE) up -d |
79 | 58 |
|
80 | | -docker-run: |
| 59 | +docker-run: ## Run with remote frontend image from GitHub |
81 | 60 | @echo "Running with remote frontend image from GitHub..." |
82 | 61 | @echo "Pulling latest frontend image..." |
83 | | - docker pull ghcr.io/yejiyang/global-tsunami-risk-map-frontend:latest |
| 62 | + docker pull $(FRONTEND_IMAGE_REMOTE) |
84 | 63 | $(COMPOSE) up -d |
85 | 64 |
|
86 | 65 | # Frontend development helpers |
87 | | -frontend-build: |
| 66 | +frontend-build: ## Build frontend assets |
88 | 67 | @echo "Building frontend..." |
89 | 68 | cd $(FRONTEND_DIR) && npm run build |
90 | 69 |
|
91 | | -frontend-serve: |
| 70 | +frontend-serve: ## Build and serve frontend locally |
92 | 71 | @echo "Serving frontend locally on http://localhost:8080" |
93 | 72 | cd $(FRONTEND_DIR)/src && $(PYTHON) -m http.server 8080 |
0 commit comments