Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (42 loc) · 1.48 KB
/
Copy pathMakefile
File metadata and controls
55 lines (42 loc) · 1.48 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
BACKEND_DIR := backend
FRONTEND_DIR := frontend
GO_SOURCES := $(shell find $(BACKEND_DIR) -name '*.go' -not -path '*/vendor/*')
DOCKER_IMAGE := coderelay-runner
DOCKER_PATH := $(BACKEND_DIR)/runner
.PHONY: backend-run backend-test backend-fmt backend-lint frontend-install frontend-dev frontend-build frontend-lint compose-up build-runner-image backend-migrate
# Build the Docker runner image if it doesn't exist
build-runner-image:
@if ! docker image inspect $(DOCKER_IMAGE) >/dev/null 2>&1; then \
echo "Docker image '$(DOCKER_IMAGE)' not found, building..."; \
docker build -t $(DOCKER_IMAGE) $(DOCKER_PATH); \
else \
echo "Docker image '$(DOCKER_IMAGE)' already exists"; \
fi
backend-run: build-runner-image
@cd $(BACKEND_DIR) && go run ./cmd/api
backend-test:
@cd $(BACKEND_DIR) && go test ./...
backend-fmt:
@gofmt -w $(GO_SOURCES)
backend-lint:
@cd $(BACKEND_DIR) && golangci-lint run ./...
frontend-install:
@cd $(FRONTEND_DIR) && npm install
frontend-dev:
@cd $(FRONTEND_DIR) && npm run dev
frontend-build:
@cd $(FRONTEND_DIR) && npm run build
frontend-lint:
@cd $(FRONTEND_DIR) && npm run lint
compose-up:
@docker compose up --build
# Run database migrations
backend-migrate:
@echo "Running database migrations..."
@cd $(BACKEND_DIR) && \
if [ -f coderelay.db ]; then \
sqlite3 coderelay.db < sqlite/migrations/002_add_elo_system.sql && \
echo "Migration completed successfully!"; \
else \
echo "Database file not found. It will be created on first run."; \
fi