-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (52 loc) · 2.12 KB
/
Makefile
File metadata and controls
65 lines (52 loc) · 2.12 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
COMPOSE_DEV := docker-compose.dev.yml
COMPOSE_TEST := docker-compose.test.yml
EXEC_APP := go run cmd/main.go
help: # Show this help message
@awk -F'#' '/^[^[:space:]].*:/ && !/^\.PHONY/ { \
target = $$1; \
comment = ($$2 ? $$2 : ""); \
printf " %-48s %s\n", target, comment \
}' Makefile
.PHONY: help
down: # Stop and remove containers
docker compose -f $(COMPOSE_DEV) down --remove-orphans -t 2
docker network prune -f
.PHONY: down
build: down # Build containers
docker compose -f $(COMPOSE_DEV) --profile prod build
.PHONY: build
up: down # Start containers
docker compose -f $(COMPOSE_DEV) --profile prod up --force-recreate
.PHONY: up
up-build: down # Build and start containers
docker compose -f $(COMPOSE_DEV) --profile prod up --build --force-recreate
.PHONY: up-build
dev: # Starts containers detatched and starts interactive shell in app container for manual runs
docker compose -f $(COMPOSE_DEV) --profile dev up -d --build
docker compose -f $(COMPOSE_DEV) exec app-dev swag init -g cmd/main.go -o ./swagger
docker compose -f $(COMPOSE_DEV) exec app-dev /bin/bash
docker compose -f $(COMPOSE_DEV) down
.PHONY: dev
test: # Execute all tests
docker compose -f $(COMPOSE_TEST) down -v --remove-orphans
docker compose -f $(COMPOSE_TEST) build
docker compose -f $(COMPOSE_TEST) up -d --remove-orphans
docker compose -f $(COMPOSE_TEST) exec -T app-dev sh run_tests.sh
docker compose -f $(COMPOSE_TEST) down -v --remove-orphans
.PHONY: test
clean: # Remove all containers and images
docker compose -f $(COMPOSE_DEV) down --remove-orphans -v
docker compose -f $(COMPOSE_TEST) down --remove-orphans -v
.PHONY: clean
swagger: # Generate Swagger documentation
swag init -g cmd/main.go -o ./swagger
.PHONY: swagger
migration: # Create a new database migration. Usage: make migration service=your_service name=your_migration_name
migrate create -ext sql -dir migrations/$(service) $(name)
.PHONY: migration
logs: # Tail logs of all containers
docker compose -f $(COMPOSE_DEV) logs -f
.PHONY: logs
logs-%: # Tail logs of a specific service. Usage: make logs-service_name
docker compose -f $(COMPOSE_DEV) logs -f $*
.PHONY: logs-%