forked from thomiceli/opengist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (53 loc) · 2.03 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
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker build_dev_docker run_dev_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test
# Specify the name of your Go binary output
BINARY_NAME := opengist
all: clean install build
all_crosscompile: clean install build_frontend build_crosscompile
install:
@echo "Installing NPM dependencies..."
@npm ci || (echo "Error: Failed to install NPM dependencies." && exit 1)
@echo "Installing Go dependencies..."
@go mod download || (echo "Error: Failed to install Go dependencies." && exit 1)
build_frontend:
@echo "Building frontend assets..."
npx vite -c public/vite.config.js build
@EMBED=1 npx postcss 'public/assets/embed-*.css' -c public/postcss.config.js --replace # until we can .nest { @tailwind } in Sass
build_backend:
@echo "Building Opengist binary..."
go build -tags fs_embed -o $(BINARY_NAME) .
build: build_frontend build_backend
build_crosscompile:
@bash ./scripts/build-all.sh
build_docker:
@echo "Building Docker image..."
docker build -t $(BINARY_NAME):latest .
build_dev_docker:
@echo "Building Docker image..."
docker build -t $(BINARY_NAME)-dev:latest --target dev .
run_dev_docker:
docker run -v .:/opengist -p 6157:6157 -p 16157:16157 $(BINARY_NAME)-dev:latest
watch_frontend:
@echo "Building frontend assets..."
npx vite -c public/vite.config.js dev --port 16157 --host
watch_backend:
@echo "Building Opengist binary..."
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'
watch:
@sh ./scripts/watch.sh
clean:
@echo "Cleaning up build artifacts..."
@rm -f $(BINARY_NAME) public/manifest.json
@rm -rf public/assets build
clean_docker:
@echo "Cleaning up Docker image..."
@docker rmi $(BINARY_NAME)
check_changes:
@echo "Checking for changes..."
@git --no-pager diff --exit-code || (echo "There are unstaged changes detected." && exit 1)
go_mod:
@go mod download
@go mod tidy
fmt:
@go fmt ./...
test:
@go test ./... -p 1