forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (83 loc) · 2.75 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
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
GOFILES := $(shell find . -name '*.go' ! -path './.go*')
SHELL := /bin/bash
define STUB
package routes
import "net/http"
const (
commonCssPath = ""
holeCssPath = ""
holeJsPath = ""
)
func Asset(w http.ResponseWriter, r *http.Request) {}
endef
bump:
@go get -u
@go mod tidy
cert:
@mkcert -install localhost
@chmod +r localhost-key.pem
.PHONY: db
db:
@ssh -t rancher@code-golf.io \
docker run -it --entrypoint psql --env-file /etc/code-golf.env --rm postgres
db-admin:
@ssh -t rancher@code-golf.io \
docker run -it --entrypoint psql --env-file /etc/code-golf.env --rm postgres -WU doadmin
deps:
@yay -S mkcert python-brotli python-fonttools
dev:
@docker-compose rm -f
@docker-compose up --build
diff-db:
@diff --color --label live --label dev --strip-trailing-cr -su \
<(ssh rancher@code-golf.io "docker run --entrypoint pg_dump \
--env-file /etc/code-golf.env --rm postgres:11.7-alpine -Os") \
<(docker-compose exec db pg_dump -OsU postgres code-golf)
fmt:
@gofmt -s -w $(GOFILES)
@goimports -w $(GOFILES)
font:
@pyftsubset ~/Downloads/fontawesome-pro-5.12.0-web/webfonts/fa-light-300.ttf \
--flavor=woff2 \
--no-hinting \
--output-file=assets/font.woff2 \
--unicodes-file=font-subset.txt
lint:
# FIXME Stub out assets if it doesn't yet exist.
ifeq ($(wildcard routes/assets.go),)
$(file > routes/assets.go, $(STUB))
endif
@docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:v1.24.0 golangci-lint run
live:
@./build-assets
@docker build --pull -t codegolf/code-golf .
@docker push codegolf/code-golf
@ssh rancher@code-golf.io " \
docker pull codegolf/code-golf && \
docker stop code-golf; \
docker rm code-golf; \
docker run \
--cap-add CAP_KILL \
--cap-add CAP_SETGID \
--cap-add CAP_SETUID \
--cap-add CAP_SYS_ADMIN \
--cap-drop ALL \
--detach \
--env-file /etc/code-golf.env \
--init \
--name code-golf \
--publish 80:1080 \
--publish 443:1443 \
--read-only \
--restart always \
--security-opt seccomp:unconfined \
--volume certs:/certs \
codegolf/code-golf"
logs:
@ssh rancher@code-golf.io docker logs -f code-golf
test:
# FIXME Stub out assets if it doesn't yet exist.
ifeq ($(wildcard routes/assets.go),)
$(file > routes/assets.go, $(STUB))
endif
@go test ./...