Skip to content

Commit 5fd0b26

Browse files
committed
dev: add make commands #118
1 parent c5bdfd8 commit 5fd0b26

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

Makefile

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Project configuration
2+
PROJECT_NAME := sk
3+
4+
# Colors for terminal output (optional)
5+
BLUE := \033[34m
6+
RESET := \033[0m
7+
8+
# Commands configuration
9+
COMPOSE_CMD = COMPOSE_PROJECT_NAME=$(PROJECT_NAME) docker compose -f docker-compose.dev.yml
10+
DOCKER_TEST_CMD = $(COMPOSE_CMD) exec app bundle exec rspec --format documentation
11+
EXEC_CMD = $(COMPOSE_CMD) exec app
12+
13+
.PHONY: help build rebuild stop start restart logs shell console format test test_fast db_reset migrate clean clean_volumes
14+
15+
# Default target
16+
help:
17+
@echo "$(BLUE)Available commands:$(RESET)"
18+
@echo " make build - Build image containers"
19+
@echo " make rebuild - Clean, build, start containers and prepare database"
20+
@echo " make stop [service] - Stop all containers or a specific service"
21+
@echo " make start [service] - Start all containers or a specific service"
22+
@echo " make restart [service] - Restart all containers or a specific service"
23+
@echo " make logs [service] - View logs of all containers or a specific service"
24+
@echo " make shell - Open a bash shell in the app container"
25+
@echo " make console - Start Rails console"
26+
@echo " make format - Auto-format code with Rubocop"
27+
@echo " make test - Run all tests"
28+
@echo " make test_fast - Run all tests and stop on first failure"
29+
@echo " make migrate - Run database migrations"
30+
@echo " make db_reset - Reset and rebuild database"
31+
@echo " make clean - Remove all containers and volumes"
32+
@echo " make clean_volumes - Remove all volumes"
33+
34+
build:
35+
$(COMPOSE_CMD) build
36+
@echo "✅ Build complete!"
37+
38+
rebuild:
39+
@echo "🚀 Setting up..."
40+
make clean
41+
make build
42+
make start
43+
sleep 2
44+
$(EXEC_CMD) bundle exec rails db:reset
45+
@echo "✅ Setup complete!"
46+
47+
stop:
48+
$(COMPOSE_CMD) stop $(filter-out $@,$(MAKECMDGOALS))
49+
50+
start:
51+
$(COMPOSE_CMD) up -d $(filter-out $@,$(MAKECMDGOALS))
52+
53+
restart:
54+
$(COMPOSE_CMD) restart $(filter-out $@,$(MAKECMDGOALS))
55+
56+
logs:
57+
$(COMPOSE_CMD) logs -f $(filter-out $@,$(MAKECMDGOALS))
58+
59+
shell:
60+
$(EXEC_CMD) bash
61+
62+
console:
63+
$(EXEC_CMD) bundle exec rails console
64+
65+
format:
66+
$(EXEC_CMD) bundle exec rubocop --autocorrect-all
67+
68+
test:
69+
$(DOCKER_TEST_CMD)
70+
71+
test_fast:
72+
$(DOCKER_TEST_CMD) --fail-fast
73+
74+
migrate:
75+
$(EXEC_CMD) bundle exec rails db:migrate
76+
77+
db_reset:
78+
$(EXEC_CMD) bundle exec rails db:drop db:create db:prepare
79+
80+
clean:
81+
$(COMPOSE_CMD) down -v
82+
83+
clean_volumes:
84+
docker volume rm -f $(PROJECT_NAME)_localstack_data $(PROJECT_NAME)_db_data
85+
86+
%:
87+
@:

0 commit comments

Comments
 (0)