-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (40 loc) · 1.33 KB
/
Makefile
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
.PHONY: all clean embed build install dev deploy
.PHONY: install-local install-local-macos
.PHONY: deploy-local deploy-vm
MACOS_SERVICE=local.golangid
PROGRAM_NAME=www-golangid
all: install
clean:
go clean -i ./cmd/$(PROGRAM_NAME)
rm -f ./$(PROGRAM_NAME)
find ./content -name "*.html" -delete
embed:
go run ./cmd/www-golangid embed
build: embed
go build ./cmd/$(PROGRAM_NAME)
install: embed
go install ./cmd/$(PROGRAM_NAME)
dev:
go run ./cmd/$(PROGRAM_NAME) -dev
deploy: build-deploy
rsync --progress ./$(PROGRAM_NAME) golang-id.org:/data/app/bin/
build-deploy: embed
unset CGO_ENABLED; \
GOOS=linux GOARCH=amd64 go build ./cmd/$(PROGRAM_NAME)
install-local: deploy-local
sudo cp ./cmd/$(PROGRAM_NAME)/$(PROGRAM_NAME).path /etc/systemd/system/
sudo cp ./cmd/$(PROGRAM_NAME)/$(PROGRAM_NAME).service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable $(PROGRAM_NAME)
sudo systemctl start $(PROGRAM_NAME)
install-local-macos:
cp cmd/$(PROGRAM_NAME)/$(MACOS_SERVICE).plist ~/Library/LaunchAgents/
mkdir -p ~/bin
CGO_ENABLED=0 go build ./cmd/www-golangid
mv $(PROGRAM_NAME) ~/bin/
launchctl load ~/Library/LaunchAgents/$(MACOS_SERVICE).plist
launchctl start $(MACOS_SERVICE)
deploy-local: build
sudo cp -f ./$(PROGRAM_NAME) /usr/local/bin/
deploy-vm: build
rsync ./$(PROGRAM_NAME) golang-id.local:~/bin/