-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (71 loc) · 2.61 KB
/
Copy pathMakefile
File metadata and controls
88 lines (71 loc) · 2.61 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
MAIN_PACKAGE_PATH := ./
BINARY_NAME := beampaw
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
.PHONY: confirm
confirm:
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
.PHONY: no-dirty
no-dirty:
git diff --exit-code > /dev/null
# ==================================================================================== #
# QUALITY CONTROL
# ==================================================================================== #
## tidy: format code and tidy modfile
.PHONY: tidy
tidy:
go fmt ./...
go mod tidy -v
# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #
## init/vars: configure the project variables
.PHONY: init/vars
init:
cp .env.example .env
ssh-keygen -t rsa -b 4096 -f id_rsa -q -N ''
## init/modules: install dependencies
.PHONY: init/modules
init/modules:
npm i
go mod tidy
## build: build the application
.PHONY: build
build:
npx tailwindcss -i ./styles.css -o ./public/index.css --minify
go build -o=/tmp/bin/${BINARY_NAME} ${MAIN_PACKAGE_PATH}
## build/docker: build the application for docker
.PHONY: build/docker
build/docker:
docker build -t ${BINARY_NAME}:latest .
## run: run the application
.PHONY: run
run: build
/tmp/bin/${BINARY_NAME}
## run/live: run the application with reloading on file changes with tailwind watch
.PHONY: run/watch
run/watch:
go run github.com/cosmtrek/air@v1.43.0 \
--build.cmd "make build" --build.bin "/tmp/bin/${BINARY_NAME}" --build.delay "100" \
--build.exclude_dir "node_modules" \
--build.include_ext "go, tpl, tmpl" \
--misc.clean_on_exit "true"
## tailwind-watch: tailwindcss watch mode
.PHONY: tailwind-watch
tailwind-watch:
npx tailwindcss -i ./styles.css -o ./public/index.css --watch
# ==================================================================================== #
# OPERATIONS
# ==================================================================================== #
## production/deploy: deploy the application to production
.PHONY: production/deploy
production/deploy: confirm tidy no-dirty
GOOS=linux GOARCH=amd64 go build -ldflags='-s' -o=/tmp/bin/linux_amd64/${BINARY_NAME} ${MAIN_PACKAGE_PATH}
echo "output to /tmp/bin/linux_amd64/${BINARY_NAME}"
echo "this script is not yet complete"