-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (82 loc) · 2.42 KB
/
Copy pathMakefile
File metadata and controls
100 lines (82 loc) · 2.42 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
92
93
94
95
96
97
98
99
100
.PHONY: help build up down logs restart clean db-migrate db-seed db-reset shell
# Default target
help:
@echo "TrackForge Docker Commands:"
@echo " make build - Build the Docker image"
@echo " make up - Start with docker-compose (recommended for local dev)"
@echo " make up-swarm - Start with Docker Swarm"
@echo " make down - Stop containers"
@echo " make logs - View logs from web service"
@echo " make restart - Restart the stack"
@echo " make db-migrate - Run database migrations"
@echo " make db-seed - Seed the database"
@echo " make db-reset - Reset database (migrate + seed)"
@echo " make shell - Open shell in web container"
@echo " make console - Open Rails console"
@echo " make clean - Remove all containers and volumes"
@echo " make status - Show container status"
# Build the Docker image
build:
docker-compose build
# Start with docker-compose (local development)
up:
docker-compose up -d
@echo "Waiting for services to start..."
@sleep 10
@echo "Stack deployed! Access at http://localhost:3000"
@echo "Run 'make db-reset' to initialize the database"
# Start with Docker Swarm (production)
up-swarm:
docker stack deploy -c prod-stack.yml trackforge
@echo "Waiting for services to start..."
@sleep 10
@echo "Stack deployed!"
# Stop containers
down:
docker-compose down 2>/dev/null || docker stack rm trackforge 2>/dev/null || true
@echo "Stopped."
# View logs
logs:
docker-compose logs -f web
logs-web:
docker-compose logs -f web
logs-db:
docker-compose logs -f db
# Restart
restart: down
@sleep 3
@make up
# Database operations
db-migrate:
@echo "Running database migrations..."
@docker-compose exec web rails db:migrate
db-seed:
@echo "Seeding database..."
@docker-compose exec web rails db:seed
db-reset: db-migrate db-seed
@echo "Database initialized!"
# Precompile assets
assets:
@echo "Precompiling assets..."
@docker-compose exec web rails assets:precompile
# Open shell in web container
shell:
@docker-compose exec web sh
# Rails console
console:
@docker-compose exec web rails console
# Show status
status:
docker-compose ps
# Clean everything
clean:
docker-compose down -v
@echo "Cleanup complete!"
# Quick start (build + up + db-reset)
quickstart: build up
@echo "Waiting for services to be ready..."
@sleep 15
@make db-reset
@echo ""
@echo "✓ TrackForge is ready!"
@echo " Access: http://localhost:3000"