-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (41 loc) · 1.18 KB
/
Makefile
File metadata and controls
53 lines (41 loc) · 1.18 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
.PHONY: build build-linux clean test fmt vet docker-build docker-push
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS = -ldflags "-s -w -X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)"
DOCKER_IMAGE ?= postgresai/rds-refresh
# Build for current platform
build:
go build $(LDFLAGS) -o rds-refresh .
# Build for Linux (for Docker containers)
build-linux:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o rds-refresh-linux-amd64 .
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o rds-refresh-linux-arm64 .
# Clean build artifacts
clean:
rm -f rds-refresh rds-refresh-linux-*
# Run tests
test:
go test -v ./...
# Format code
fmt:
go fmt ./...
# Run go vet
vet:
go vet ./...
# Download dependencies
deps:
go mod download
go mod tidy
# Run locally (requires config.yaml)
run:
go run . -config config.yaml
# Run dry-run locally
dry-run:
go run . -config config.yaml -dry-run
# Build Docker image
docker-build:
docker build -t $(DOCKER_IMAGE):$(VERSION) -t $(DOCKER_IMAGE):latest .
# Push Docker image
docker-push:
docker push $(DOCKER_IMAGE):$(VERSION)
docker push $(DOCKER_IMAGE):latest