-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
36 lines (26 loc) · 1007 Bytes
/
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
BIN := gomods
MAINTAINER := okkur
VERSION := `cat $(VERSION_FILE)`
IMAGE := $(MAINTAINER)/$(BIN):$(VERSION)
BUILD_GOOS := $(if $(GOOS),$(GOOS),linux)
BUILD_GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
CONTAINER ?= $(BIN)
.DEFAULT_GOAL := build
build:
cd cmd/gomods && \
GO111MODULE=on CGO_ENABLED=0 GOARCH=$(BUILD_GOARCH) GOOS=$(BUILD_GOOS) go build -ldflags="-s -w"
mv cmd/gomods/gomods ./$(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.13-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.13-alpine /bin/sh \
-c "cd /source && apk add git gcc musl-dev make && make build"
version:
@echo $(VERSION)