Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (53 loc) · 1.46 KB
/
Copy pathMakefile
File metadata and controls
70 lines (53 loc) · 1.46 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
.PHONY: build run test clean
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GORUN=$(GOCMD) run
GOTEST=$(GOCMD) test
GOCLEAN=$(GOCMD) clean
GOMOD=$(GOCMD) mod
# Binary name
BINARY_NAME=airbridge
BINARY_PATH=bin/$(BINARY_NAME)
# Version from git tags
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
VERSION_PKG=github.com/kenyonj/airbridge/internal/web
LDFLAGS=-ldflags="-X $(VERSION_PKG).Version=$(VERSION)"
# Build directories
BUILD_DIR=bin
all: build
build:
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BINARY_PATH) ./cmd/airbridge
run:
$(GORUN) ./cmd/airbridge
test:
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
rm -rf $(BUILD_DIR)
deps:
$(GOMOD) download
$(GOMOD) tidy
# Development helpers
fmt:
gofmt -w .
lint:
golangci-lint run
# Docker
DOCKER_IMAGE=ghcr.io/kenyonj/airbridge
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
docker-build:
docker build --build-arg VERSION=$(VERSION) -t $(DOCKER_IMAGE):latest -t $(DOCKER_IMAGE):$(VERSION) .
docker-run:
docker run --rm --network=host -v airbridge-data:/data $(DOCKER_IMAGE):latest
docker-push:
docker push $(DOCKER_IMAGE):latest
docker push $(DOCKER_IMAGE):$(VERSION)
# Install dependencies for CGO (libraop)
setup-libraop:
@echo "Setting up libraop..."
@mkdir -p vendor/libraop
git clone --depth 1 https://github.com/philippe44/libraop.git vendor/libraop
cd vendor/libraop && git submodule update --init
@echo "libraop cloned to vendor/libraop"