summaryrefslogtreecommitdiff
path: root/Makefile
blob: f3051aeaaa4bdd7c4892692fb9aa7278b5ca931f (plain)
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
GOPATH ?= $(HOME)/.local/share/go
WAILS  := $(GOPATH)/bin/wails
SERVER := root@178.20.40.99
export GOPATH

.PHONY: all server client-linux client-windows installer test clean deploy release

all: server client-linux

# --- Server ---

server:
	go build -o build/vpnem-server ./cmd/server

# --- Client ---

client-linux:
	cd cmd/client && $(WAILS) build -platform linux/amd64 -o vpnem -tags with_gvisor
	cp cmd/client/build/bin/vpnem build/vpnem-linux-amd64

client-windows:
	cd cmd/client && CC=x86_64-w64-mingw32-gcc $(WAILS) build -platform windows/amd64 -o vpnem.exe -tags with_gvisor
	cp cmd/client/build/bin/vpnem.exe build/vpnem-windows-amd64.exe

installer:
	CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-H windowsgui" -o build/vpnem-installer.exe ./cmd/installer

# --- Test ---

test:
	go test ./... -v

# --- Deploy: server code only ---

deploy:
	rsync -avz --exclude '.git' --exclude 'build' --exclude '*.srs' --exclude '.claude' \
		./ $(SERVER):/opt/vpnem/
	ssh $(SERVER) "cd /opt/vpnem && docker compose up -d --build"
	@echo "Verify: curl https://vpn.em-sysadmin.xyz/health"

# --- Release: build all + deploy binaries + bump version ---

release: client-linux client-windows installer
	rm -f build/vpnem-linux-amd64
	cp cmd/client/build/bin/vpnem build/vpnem-linux-amd64
	scp build/vpnem-linux-amd64 build/vpnem-windows-amd64.exe build/vpnem-installer.exe \
		$(SERVER):/opt/vpnem/data/releases/
	scp data/version.json $(SERVER):/opt/vpnem/data/version.json
	rsync -avz --exclude '.git' --exclude 'build' --exclude '*.srs' --exclude '.claude' \
		./ $(SERVER):/opt/vpnem/
	ssh $(SERVER) "cd /opt/vpnem && docker compose restart"
	@echo ""
	@curl -s https://vpn.em-sysadmin.xyz/api/v1/version
	@echo ""
	@echo "Release deployed."

# --- Clean ---

clean:
	rm -rf build/ cmd/client/build/