forked from kenrmayfield/filebrowserquantum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
164 lines (136 loc) Β· 7.07 KB
/
makefile
File metadata and controls
164 lines (136 loc) Β· 7.07 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
# Use bash on all platforms
# Windows users: Requires Git Bash (comes with Git for Windows: https://git-scm.com/download/win)
# Add C:\Program Files\Git\bin to your PATH, or run make from Git Bash terminal
ifeq ($(OS),Windows_NT)
SHELL := C:/Program Files/Git/bin/bash.exe
.SHELLFLAGS := -ec
else
SHELL := /bin/bash
endif
# git checkout remote branch PR
# git fetch origin pull/####/head:pr-####
.SILENT:
.PHONY: setup update build build-docker build-backend build-frontend dev run generate-docs
.PHONY: lint-frontend lint-backend lint test test-backend test-frontend check-all
.PHONY: check-translations sync-translations test-playwright run-proxy screenshots
setup:
echo "creating ./backend/test_config.yaml for local testing..."
if [ ! -f backend/test_config.yaml ]; then \
cp backend/config.yaml backend/test_config.yaml; \
fi
echo "installing backend tooling..."
cd backend && go get tool
cd backend/http && mkdir -p embed && touch embed/.gitignore
echo "installing npm requirements for frontend..."
cd frontend && npm i
update:
cd backend && go get -u ./... && go mod tidy
cd frontend && npm update
build: build-frontend build-backend
build-docker:
docker build --build-arg="VERSION=testing" --build-arg="REVISION=n/a" -t plashost/filebrowser -f _docker/Dockerfile .
build-docker-slim:
docker build --build-arg="VERSION=testing" --build-arg="REVISION=n/a" -t plashost/filebrowser -f _docker/Dockerfile.slim .
build-backend:
@echo "Building backend..."
cd backend && go build -o filebrowser --ldflags="-w -s -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.CommitSHA=testingCommit' -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.Version=testing'"
@echo "β Backend built successfully"
# New dev target with hot-reloading for frontend and backend
dev: generate-docs
@echo "Starting dev servers... Press Ctrl+C to stop."
@cd frontend && DEV_BUILD=true npm run watch & \
FRONTEND_PID=$$!; \
cd backend && export FILEBROWSER_DEVMODE=true && go tool air $$([ "$(OS)" = "Windows_NT" ] && echo "-c .air.windows.toml" || echo "") & \
BACKEND_PID=$$!; \
trap 'echo "Stopping..."; kill $$FRONTEND_PID $$BACKEND_PID 2>/dev/null; sleep 1; kill -9 $$FRONTEND_PID $$BACKEND_PID 2>/dev/null; exit 0' INT TERM; \
wait $$FRONTEND_PID $$BACKEND_PID 2>/dev/null || true
run: build-frontend generate-docs
cd backend && go tool swag init --output swagger/docs
@if [ "$$(uname)" = "Darwin" ]; then \
sed -i '' '/func init/,+3d' backend/swagger/docs/docs.go; \
else \
sed -i '/func init/,+3d' backend/swagger/docs/docs.go; \
fi
cd backend && CGO_ENABLED=1 FILEBROWSER_DEVMODE=true go run --tags=mupdf \
--ldflags="-w -s -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.CommitSHA=testingCommit' -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.Version=testing'" . -c test_config.yaml
generate-docs:
@echo "NOTE: Run 'make setup' if you haven't already."
@echo "Generating swagger docs..."
cd backend && go tool swag init --output swagger/docs
@if [ "$$(uname)" = "Darwin" ]; then \
sed -i '' '/func init/,+3d' backend/swagger/docs/docs.go; \
else \
sed -i '/func init/,+3d' backend/swagger/docs/docs.go; \
fi
@echo "Generating frontend config..."
cd backend && FILEBROWSER_GENERATE_CONFIG=true go run .
build-frontend:
@echo "Building frontend..."
cd frontend && npm run build
@echo "β Frontend built successfully"
lint-frontend:
cd frontend && npm run lint
lint-backend:
cd backend && go tool golangci-lint run --path-prefix=backend
lint: lint-backend lint-frontend
test: test-backend test-frontend
check-all: lint test check-translations
check-translations:
cd frontend && npm run i18n:check
sync-translations:
cd frontend && npm run i18n:sync
test-backend:
cd backend && go test -race -timeout=10s ./...
test-frontend:
cd frontend && npm run test
test-playwright: build-frontend
cd backend && GOOS=linux go build -o filebrowser .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-jwt .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-proxy .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-general .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-previews .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-noauth .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-settings .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-oidc .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-sharing .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-no-config .
docker build -t filebrowser-playwright-tests -f _docker/Dockerfile.playwright-screenshots .
run-proxy: build-frontend
cd _docker && docker compose up -d --build nginx-proxy-auth filebrowser
run-jwt: build-frontend
cd _docker && docker compose up -d --build nginx-proxy-jwt filebrowser-jwt
# once local playwright server is running, you can also watch the tests interactively with:
# cd frontend && npx playwright test --project dark-screenshots --ui
screenshots: build-frontend
cd backend && GOOS=linux go build -o filebrowser --ldflags="-w -s -X 'github.com/gtsteffaniak/filebrowser/backend/common/version.Version=latest'" .
@echo "Running screenshots..."
cd _docker && docker compose down && docker compose up --build local-playwright-screenshots
@if [ -d ../filebrowserDocs ]; then \
rm -rf ../filebrowserDocs/static/images/generated/; \
cp -r ./frontend/generated ../filebrowserDocs/static/images/; \
echo "Copied screenshots to ../filebrowserDocs/static/images/generated/"; \
fi
profile:
@echo "Note: start the backend server with 'make dev' first"
@echo "Results will be in ./backend/debug/ directory"
@mkdir -p backend/debug
@echo "Downloading heap profile..."
@curl -s http://localhost:6060/debug/pprof/heap > backend/debug/heap.pb.gz || (echo "Error: Could not download heap profile. Is the server running?" && exit 1)
@echo "Generating heap profile (SVG)..."
cd backend && go tool pprof -svg -output debug/heap.svg debug/heap.pb.gz
@echo "Generating heap profile (text)..."
cd backend && go tool pprof -text debug/heap.pb.gz > debug/heap.txt 2>&1
@echo "Downloading CPU profile..."
@curl -s "http://localhost:6060/debug/pprof/profile?seconds=30" > backend/debug/cpu.pb.gz || (echo "Error: Could not download CPU profile. Is the server running?" && exit 1)
@echo "Generating CPU profile (SVG)..."
cd backend && go tool pprof -svg -output debug/cpu.svg debug/cpu.pb.gz
@echo "Generating CPU profile (text)..."
cd backend && go tool pprof -text debug/cpu.pb.gz > debug/cpu.txt 2>&1
@echo "β Generated debug files: heap.pb.gz, heap.svg, heap.txt, cpu.pb.gz, cpu.svg, cpu.txt"
memory:
@echo "Fetching memory stats from running server..."
@echo "Note: start the backend server with 'make dev' first"
@echo "Usage: make memory [PORT=8080]"
@PORT=$${PORT:-8080}; \
curl -s http://localhost:$$PORT/api/memory | python3 -m json.tool || \
(echo "Error: Could not fetch memory stats. Is the server running on port $$PORT?" && exit 1)