Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (59 loc) · 1.88 KB
/
Copy pathMakefile
File metadata and controls
76 lines (59 loc) · 1.88 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
.PHONY: build build-ui build-all run run-worker dev dev-worker dev-deps test vet fmt lint clean
BINARY := posta
BUILD_DIR := bin
UI_DIR := web
# Where `go build` picks the dashboard up for embedding (see internal/web).
EMBED_UI_DIR := internal/web/dist
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS := -X github.com/goposta/posta/internal/config.Version=$(VERSION) -X github.com/goposta/posta/internal/config.CommitID=$(COMMIT)
build:
go build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) ./cmd/posta
build-ui: ## Build the dashboard and stage it for embedding (internal/web/dist)
cd $(UI_DIR) && npm install && npm run build
# Stage the build output where //go:embed reads it, keeping the committed
# .gitkeep so `go build` still works on a clean tree.
rm -rf $(EMBED_UI_DIR)
cp -r $(UI_DIR)/dist $(EMBED_UI_DIR)
touch $(EMBED_UI_DIR)/.gitkeep
build-all: build-ui build ## Build the dashboard, then a self-contained binary
run: build
./$(BUILD_DIR)/$(BINARY) server
run-worker: build
./$(BUILD_DIR)/$(BINARY) worker
run-ui:
cd $(UI_DIR) && npm run dev
dev: build
./$(BUILD_DIR)/$(BINARY) server
dev-worker: build
./$(BUILD_DIR)/$(BINARY) worker
dev-ui:
cd $(UI_DIR) && npm run dev
dev-deps:
docker run -d --name posta-postgres \
-e POSTGRES_USER=posta \
-e POSTGRES_PASSWORD=posta \
-e POSTGRES_DB=posta \
-p 5432:5432 \
postgres:17-alpine
docker run -d --name posta-redis \
-p 6379:6379 \
redis:7-alpine
dev-deps-stop:
docker stop posta-postgres posta-redis || true
docker rm posta-postgres posta-redis || true
test:
go test ./...
vet:
go vet ./...
fmt:
gofmt -w .
clean:
rm -rf $(BUILD_DIR)
rm -rf $(EMBED_UI_DIR)
mkdir -p $(EMBED_UI_DIR) && touch $(EMBED_UI_DIR)/.gitkeep
rm -rf $(UI_DIR)/dist
tidy:
go mod tidy
lint:
golangci-lint run