-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (87 loc) · 3.26 KB
/
Copy pathMakefile
File metadata and controls
101 lines (87 loc) · 3.26 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
# Build variables
BINARY_NAME=netronome
BUILD_DIR=bin
DOCKER_IMAGE=netronome
.PHONY: all build clean run docker-build docker-run watch dev dev-expose lint themes-fetch themes-clean
# Private repo holding the premium theme CSS. Absent in forks and source builds,
# which ship the default theme only.
THEMES_REPO=github.com/autobrr/qui-premium-themes
THEMES_DIR=web/src/themes/premium
all: build
# Fetch premium themes from the private repository. Requires THEMES_REPO_TOKEN;
# without it the build succeeds and simply ships no premium themes.
themes-fetch:
@if [ -n "$$THEMES_REPO_TOKEN" ]; then \
echo "Fetching premium themes..."; \
rm -rf $(THEMES_DIR) .themes-temp && \
git clone --depth=1 --filter=blob:none --sparse \
https://$$THEMES_REPO_TOKEN@$(THEMES_REPO).git .themes-temp && \
cd .themes-temp && git sparse-checkout set --cone netronome && cd .. && \
mkdir -p $(THEMES_DIR) && \
cp .themes-temp/netronome/*.css $(THEMES_DIR)/ && \
rm -rf .themes-temp && \
echo "Premium themes fetched successfully"; \
else \
echo "THEMES_REPO_TOKEN not set, skipping premium themes"; \
fi
themes-clean:
@echo "Cleaning premium themes..."
@rm -rf $(THEMES_DIR)
build: themes-fetch
@echo "Building frontend and backend..."
@mkdir -p $(BUILD_DIR)
@mkdir -p web/dist
@cd web && pnpm install && pnpm build
@touch web/dist/.gitkeep
@go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/netronome
clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@rm -rf web/dist
@mkdir -p web/dist
@touch web/dist/.gitkeep
@rm -rf web/node_modules
run: build
@echo "Running application..."
@./$(BUILD_DIR)/$(BINARY_NAME) serve --config config/config.toml
docker-build:
@echo "Building Docker image..."
docker build -f distrib/docker/Dockerfile -t $(DOCKER_IMAGE) .
docker-run: docker-build
@echo "Running Docker container..."
docker run -p 7575:7575 $(DOCKER_IMAGE)
# Development with live reload
dev:
@echo "Starting development servers..."
@GIN_MODE=debug tmux new-session -d -s dev 'cd web && pnpm dev'
@touch web/dist/.gitkeep > /dev/null 2>&1
@GIN_MODE=debug tmux split-window -h 'make watch'
@tmux -2 attach-session -d
# Development with live reload exposed on network
dev-expose:
@echo "Starting development servers (exposed on network)..."
@echo "Frontend will be available at http://0.0.0.0:5173"
@echo "Backend will be available at http://0.0.0.0:7575"
@echo "You can access from other devices using your machine's IP address"
@GIN_MODE=debug tmux new-session -d -s dev 'cd web && pnpm dev --host 0.0.0.0'
@touch web/dist/.gitkeep > /dev/null 2>&1
@GIN_MODE=debug tmux split-window -h 'make watch'
@tmux -2 attach-session -d
watch:
@if command -v air > /dev/null; then \
GIN_MODE=debug air -c .config/air.toml -- serve --config config/config.toml; \
echo "Watching...";\
else \
read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/cosmtrek/air@latest; \
GIN_MODE=debug air -c .config/air.toml -- serve --config config/config.toml; \
echo "Watching...";\
else \
echo "You chose not to install air. Exiting..."; \
exit 1; \
fi; \
fi
lint:
@echo "Linting changed Go code..."
golangci-lint run --new-from-merge-base=develop --timeout=5m