-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
209 lines (180 loc) · 6.55 KB
/
Makefile
File metadata and controls
209 lines (180 loc) · 6.55 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
.PHONY: install dev dev-https dev-insecure build lint seed import test clean clean-db clean-all clean-deps docker-build docker-run docker-run-insecure docker-stop docker-logs docker-clean docker-shell docker-db-backup docker-db-restore compose-up compose-up-insecure compose-down compose-logs compose-restart compose-clean help
help:
@echo "Development Commands"
@echo "===================="
@echo "make install - Install npm dependencies"
@echo "make dev - Start development server (HTTP)"
@echo "make dev-https - Start dev server with auto HTTPS (self-signed cert via Next.js)"
@echo "make dev-insecure - Start dev server with TLS verification disabled (INSECURE_TLS=1)"
@echo "make build - Full production build (seed + import + build)"
@echo "make lint - Run ESLint"
@echo "make seed - Create/reset database tables"
@echo "make import - Import YAML exercises into database"
@echo "make test - Run tests (placeholder)"
@echo ""
@echo "Cleanup Commands"
@echo "================"
@echo "make clean - Clean build artifacts and temp files (safe)"
@echo "make clean-db - Clean database only"
@echo "make clean-all - Clean everything including DB (with confirmation)"
@echo "make clean-deps - Remove node_modules (with confirmation)"
@echo ""
@echo "Docker CLI Commands"
@echo "===================="
@echo "make docker-build - Build Docker image"
@echo "make docker-run - Run container (Docker CLI)"
@echo "make docker-run-insecure - Run container with TLS verification disabled (INSECURE_TLS=1)"
@echo "make docker-stop - Stop container"
@echo "make docker-logs - View container logs"
@echo "make docker-clean - Remove container and image"
@echo "make docker-shell - Open shell in running container"
@echo "make docker-db-backup - Backup SQLite database"
@echo "make docker-db-restore - Restore SQLite database"
@echo ""
@echo "Docker Compose Commands"
@echo "======================"
@echo "make compose-up - Start services with Docker Compose"
@echo "make compose-up-insecure - Start services with TLS verification disabled (INSECURE_TLS=1)"
@echo "make compose-down - Stop services"
@echo "make compose-logs - View Docker Compose logs"
@echo "make compose-restart - Restart services"
@echo "make compose-clean - Stop and remove volumes (loses data)"
# Development Commands
install:
npm install
dev:
npm run dev
dev-https:
npm run dev:https
dev-insecure:
INSECURE_TLS=1 npm run dev
build:
mkdir -p data
npm run db:seed
npm run exercises:import
npm run build
lint:
npm run lint
seed:
mkdir -p data
npm run db:seed
import:
npm run exercises:import
test:
@echo "No test runner configured yet"
# Cleanup Commands
clean:
@echo "Cleaning build artifacts and temp files..."
rm -rf .next
rm -rf out
rm -rf coverage
rm -f *.tsbuildinfo
find . -name ".DS_Store" -type f -delete
@echo "Clean complete (database preserved)"
clean-db:
@echo "Cleaning database..."
rm -rf data
@echo "Database removed"
clean-all:
@echo "This will remove ALL build artifacts, temp files, AND the database!"
@read -p "Are you sure? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
rm -rf .next out coverage data backups; \
rm -f *.tsbuildinfo; \
find . -name ".DS_Store" -type f -delete; \
echo "All temp data removed"; \
else \
echo "Cancelled"; \
fi
clean-deps:
@echo "This will remove node_modules (requires reinstall)!"
@read -p "Are you sure? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
rm -rf node_modules; \
echo "Dependencies removed. Run 'make install' to reinstall"; \
else \
echo "Cancelled"; \
fi
# Docker CLI Commands
docker-build:
@echo "Building Docker image..."
docker build -t learning-platform:latest .
@echo "Build complete: learning-platform:latest"
docker-run: docker-build
@echo "Running container..."
docker run -d \
-p 3000:3000 \
-e SESSION_SECRET=supersecretkeysupersecretkey3232 \
-v learning-platform-data:/app/data \
--name learning-platform \
--restart unless-stopped \
learning-platform:latest
@echo "Container started: http://localhost:3000"
docker-run-insecure: docker-build
@echo "Running container with TLS verification disabled..."
docker run -d \
-p 3000:3000 \
-e SESSION_SECRET=supersecretkeysupersecretkey3232 \
-e INSECURE_TLS=1 \
-v learning-platform-data:/app/data \
--name learning-platform \
--restart unless-stopped \
learning-platform:latest
@echo "Container started (insecure TLS): http://localhost:3000"
docker-stop:
@echo "Stopping container..."
docker stop learning-platform || true
docker rm learning-platform || true
@echo "Container stopped"
docker-logs:
docker logs -f learning-platform
docker-clean: docker-stop
@echo "Removing image..."
docker rmi learning-platform:latest || true
docker volume rm learning-platform-data || true
@echo "Cleanup complete"
docker-shell:
docker exec -it learning-platform sh
docker-db-backup:
@echo "Backing up database..."
mkdir -p ./backups
docker cp learning-platform:/app/data/learning-platform.db ./backups/learning-platform-$(shell date +%Y%m%d-%H%M%S).db
@echo "Database backed up to ./backups/"
docker-db-restore:
@echo "Restoring database from latest backup..."
@latest=$$(ls -t ./backups/learning-platform-*.db 2>/dev/null | head -1); \
if [ -z "$$latest" ]; then \
echo "No backups found in ./backups/"; \
exit 1; \
fi; \
docker cp $$latest learning-platform:/app/data/learning-platform.db; \
docker restart learning-platform; \
echo "Database restored and container restarted"
# Docker Compose Commands
compose-up:
@echo "Starting services with Docker Compose..."
docker-compose up -d
@echo "Services started: http://localhost:3000"
compose-up-insecure:
@echo "Starting services with TLS verification disabled..."
INSECURE_TLS=1 docker-compose up -d
@echo "Services started (insecure TLS): http://localhost:3000"
compose-down:
@echo "Stopping services..."
docker-compose down
@echo "Services stopped"
compose-logs:
docker-compose logs -f
compose-restart:
@echo "Restarting services..."
docker-compose restart
@echo "Services restarted"
compose-clean:
@echo "This will remove all data and volumes!"
@read -p "Are you sure? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
docker-compose down -v; \
echo "Services and data removed"; \
else \
echo "Cancelled"; \
fi