2019-06-20 18:36:40 -05:00
|
|
|
export GO111MODULE=on
|
2019-07-20 19:30:58 -05:00
|
|
|
TOP_LEVEL=$(shell git rev-parse --show-toplevel)
|
2019-09-16 13:01:59 -05:00
|
|
|
COMMIT_HASH=$(shell git describe --always --tags --long)
|
|
|
|
COMMIT=$(if $(shell git status --porcelain --untracked-files=no),$(COMMIT_HASH)-dirty,$(COMMIT_HASH))
|
2019-08-14 14:35:51 -05:00
|
|
|
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
|
|
|
|
PATH := bin:$(PATH)
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: doc binary debug test check
|
|
|
|
|
|
|
|
.PHONY: binary
|
|
|
|
binary: doc
|
2019-09-16 13:01:59 -05:00
|
|
|
go build -v -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT}" -o bin/zot -tags=jsoniter ./cmd/zot
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: debug
|
|
|
|
debug: doc
|
2019-09-16 13:01:59 -05:00
|
|
|
go build -v -gcflags all='-N -l' -ldflags "-X github.com/anuvu/zot/pkg/api.Commit=${COMMIT}" -o bin/zot-debug -tags=jsoniter ./cmd/zot
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2019-12-13 17:22:56 -05:00
|
|
|
$(shell mkdir -p test/data; cd test/data; ../scripts/gen_certs.sh; cd ${TOP_LEVEL})
|
2019-06-26 16:31:43 -05:00
|
|
|
go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
2019-06-20 18:36:40 -05:00
|
|
|
|
2020-01-24 16:32:38 -05:00
|
|
|
.PHONY: covhtml
|
|
|
|
covhtml:
|
|
|
|
go tool cover -html=coverage.txt -o coverage.html
|
|
|
|
|
2019-06-20 18:36:40 -05:00
|
|
|
.PHONY: check
|
2019-08-15 11:34:54 -05:00
|
|
|
check: .bazel/golangcilint.yaml
|
2019-12-13 00:53:18 -05:00
|
|
|
golangci-lint --version || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.21.0
|
|
|
|
golangci-lint --config .bazel/golangcilint.yaml run --enable-all ./cmd/... ./pkg/...
|
2019-06-20 18:36:40 -05:00
|
|
|
|
2019-08-28 17:58:00 -05:00
|
|
|
docs/docs.go:
|
2019-09-03 15:21:05 -05:00
|
|
|
swag -v || go install github.com/swaggo/swag/cmd/swag
|
2019-06-20 18:36:40 -05:00
|
|
|
swag init -g pkg/api/routes.go
|
|
|
|
|
2019-08-28 17:58:00 -05:00
|
|
|
.PHONY: doc
|
|
|
|
doc: docs/docs.go
|
|
|
|
|
2019-06-20 18:36:40 -05:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2019-12-11 17:07:24 -05:00
|
|
|
rm -f bin/zot*
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: run
|
|
|
|
run: binary test
|
|
|
|
./bin/zot serve examples/config-test.json
|
2019-08-14 14:35:51 -05:00
|
|
|
|
|
|
|
.PHONY: binary-container
|
|
|
|
binary-container:
|
2020-01-24 12:47:16 -05:00
|
|
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile.build -t zot-build:latest .
|
2019-08-14 14:35:51 -05:00
|
|
|
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/anuvu/zot \
|
2020-01-24 12:47:16 -05:00
|
|
|
zot-build:latest make
|
2019-08-14 18:26:25 -05:00
|
|
|
|
|
|
|
.PHONY: binary-stacker
|
|
|
|
binary-stacker:
|
|
|
|
stacker build --substitute PWD=$$PWD --no-cache
|
2020-01-24 12:54:38 -05:00
|
|
|
|
|
|
|
.PHONY: image
|
|
|
|
image:
|
|
|
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile -t zot:latest .
|