forked from txtdirect/txtdirect
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
45 lines (34 loc) · 1.41 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
BIN := txtdirect
DOMAIN := c.txtdirect.org
VERSION := $(shell cat ./VERSION)
GITCOMMIT:=$(shell git describe --dirty --always)
IMAGE := $(DOMAIN)/$(BIN):$(VERSION)
CODEPATH := $(shell go list -m)
BUILD_GOOS := $(if $(GOOS),$(GOOS),linux)
BUILD_GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
CONTAINER ?= $(BIN)
.DEFAULT_GOAL := build
build:
cd cmd/txtdirect && \
GO111MODULE=on CGO_ENABLED=0 GOARCH=$(BUILD_GOARCH) GOOS=$(BUILD_GOOS) go build -ldflags="-s -w -X $(CODEPATH)/txtdirectmain.TXTDirectVersion=$(VERSION) -X $(CODEPATH)/txtdirectmain.GitCommit=$(GITCOMMIT)"
mv cmd/txtdirect/txtdirect ./$(BIN)
test:
GO111MODULE=on go test -v `go list ./...`
image-build: docker-build
docker build -t $(IMAGE) .
docker-run: image-build
docker run --name $(CONTAINER) $(IMAGE)
docker-test:
docker run --network=host -v $(shell pwd):/source -v $(GOPATH)/pkg/mod:/go/pkg/mod golang:1.14-alpine /bin/sh \
-c "cd /source && apk add git gcc musl-dev make && GOROOT=\"/usr/local/go\" make test"
docker-build:
docker run --network=host -v $(shell pwd):/source -v $(GOPATH)/pkg/mod:/go/pkg/mod golang:1.14-alpine /bin/sh \
-c "cd /source && apk add git gcc musl-dev make && make build"
endtoend-test: docker-build
docker build -t $(IMAGE)-dirty .
cd e2e && \
docker build -t c.txtdirect.org/tester:dirty . && \
docker run -d -p 5000:5000 --name registry registry:2.7.1 && \
VERSION=$(VERSION)-dirty go run main.go
version:
@echo $(VERSION)