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)
|
2021-10-15 10:05:00 -05:00
|
|
|
GO_VERSION=$(shell go version | awk '{print $$3}')
|
2019-09-16 13:01:59 -05:00
|
|
|
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)
|
2020-07-09 02:10:11 -05:00
|
|
|
TMPDIR := $(shell mktemp -d)
|
2020-11-05 20:57:06 -05:00
|
|
|
STACKER := $(shell which stacker)
|
2021-12-03 12:42:03 -05:00
|
|
|
OS ?= linux
|
|
|
|
ARCH ?= amd64
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: all
|
2021-12-15 17:14:53 -05:00
|
|
|
all: swagger binary binary-minimal binary-debug binary-arch binary-arch-minimal exporter-minimal test test-clean check
|
2020-10-14 16:47:20 -05:00
|
|
|
|
|
|
|
.PHONY: binary-minimal
|
2021-10-20 16:01:06 -05:00
|
|
|
binary-minimal: swagger
|
2021-12-07 15:51:04 -05:00
|
|
|
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-minimal -tags minimal,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: binary
|
2021-10-15 10:05:00 -05:00
|
|
|
binary: swagger
|
2021-12-07 15:51:04 -05:00
|
|
|
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot
|
2019-06-20 18:36:40 -05:00
|
|
|
|
2021-12-07 15:51:04 -05:00
|
|
|
.PHONY: binary-debug
|
|
|
|
binary-debug: swagger
|
|
|
|
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-debug -tags extended,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot
|
2021-10-15 10:05:00 -05:00
|
|
|
|
2021-12-15 17:14:53 -05:00
|
|
|
.PHONY: binary-arch-minimal
|
|
|
|
binary-arch-minimal: swagger
|
|
|
|
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(ARCH)-minimal -tags minimal,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot
|
|
|
|
|
|
|
|
.PHONY: binary-arch
|
|
|
|
binary-arch: swagger
|
|
|
|
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot
|
|
|
|
|
2021-10-15 10:05:00 -05:00
|
|
|
.PHONY: exporter-minimal
|
|
|
|
exporter-minimal: swagger
|
2021-12-03 12:42:03 -05:00
|
|
|
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-exporter -tags minimal,containers_image_openpgp -v -trimpath ./cmd/exporter
|
2019-06-20 18:36:40 -05:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2020-12-21 16:43:33 -05:00
|
|
|
$(shell mkdir -p test/data; cd test/data; ../scripts/gen_certs.sh; cd ${TOP_LEVEL}; sudo skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:7 oci:${TOP_LEVEL}/test/data/zot-test:0.0.1;sudo skopeo --insecure-policy copy -q docker://public.ecr.aws/t0x7q1g8/centos:8 oci:${TOP_LEVEL}/test/data/zot-cve-test:0.0.1)
|
2021-07-06 11:50:46 -05:00
|
|
|
$(shell sudo mkdir -p /etc/containers/certs.d/127.0.0.1:8089/; sudo cp test/data/client.* /etc/containers/certs.d/127.0.0.1:8089/; sudo cp test/data/ca.* /etc/containers/certs.d/127.0.0.1:8089/;)
|
|
|
|
$(shell sudo chmod a=rwx /etc/containers/certs.d/127.0.0.1:8089/*.key)
|
2021-11-22 03:12:01 -05:00
|
|
|
go test -tags extended,containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile=coverage-extended.txt -covermode=atomic ./...
|
2021-10-15 10:05:00 -05:00
|
|
|
go test -tags minimal,containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile=coverage-minimal.txt -covermode=atomic ./...
|
2019-06-20 18:36:40 -05:00
|
|
|
|
2021-07-06 11:50:46 -05:00
|
|
|
.PHONY: test-clean
|
|
|
|
test-clean:
|
|
|
|
$(shell sudo rm -rf /etc/containers/certs.d/127.0.0.1:8089/)
|
|
|
|
|
2020-01-24 16:32:38 -05:00
|
|
|
.PHONY: covhtml
|
|
|
|
covhtml:
|
2021-10-15 10:05:00 -05:00
|
|
|
tail -n +2 coverage-minimal.txt > tmp.txt && mv tmp.txt coverage-minimal.txt
|
|
|
|
cat coverage-extended.txt coverage-minimal.txt > coverage.txt
|
2020-01-24 16:32:38 -05:00
|
|
|
go tool cover -html=coverage.txt -o coverage.html
|
|
|
|
|
2019-06-20 18:36:40 -05:00
|
|
|
.PHONY: check
|
2021-05-04 12:28:40 -05:00
|
|
|
check: ./golangcilint.yaml
|
2020-05-11 17:13:24 -05:00
|
|
|
golangci-lint --version || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.26.0
|
2021-10-15 10:05:00 -05:00
|
|
|
golangci-lint --config ./golangcilint.yaml run --enable-all --build-tags extended,containers_image_openpgp ./...
|
|
|
|
golangci-lint --config ./golangcilint.yaml run --enable-all --build-tags minimal,containers_image_openpgp ./...
|
2019-06-20 18:36:40 -05:00
|
|
|
|
2021-10-20 16:01:06 -05:00
|
|
|
swagger/docs.go:
|
2019-09-03 15:21:05 -05:00
|
|
|
swag -v || go install github.com/swaggo/swag/cmd/swag
|
2021-10-20 16:01:06 -05:00
|
|
|
swag init -o swagger -g pkg/api/routes.go
|
2019-06-20 18:36:40 -05:00
|
|
|
|
2021-10-20 16:01:06 -05:00
|
|
|
.PHONY: swagger
|
|
|
|
swagger: swagger/docs.go
|
2019-08-28 17:58:00 -05:00
|
|
|
|
2020-12-03 14:33:38 -05:00
|
|
|
.PHONY: update-licenses
|
|
|
|
update-licenses:
|
|
|
|
go get github.com/google/go-licenses
|
|
|
|
$(shell echo "Module | License URL | License" > THIRD-PARTY-LICENSES.md; echo "---|---|---" >> THIRD-PARTY-LICENSES.md; for i in $$(cat go.sum | awk '{print $$1}'); do l=$$(go-licenses csv $$i 2>/dev/null); if [ $$? -ne 0 ]; then continue; fi; echo $$l | tr \, \| | tr ' ' '\n'; done | sort -u >> THIRD-PARTY-LICENSES.md)
|
|
|
|
|
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-11-05 20:39:14 -05:00
|
|
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile -t zot-build:latest .
|
|
|
|
|
|
|
|
.PHONY: run-container
|
|
|
|
run-container:
|
2021-12-03 22:50:58 -05:00
|
|
|
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/project-zot/zot \
|
2020-11-05 20:39:14 -05:00
|
|
|
zot-build:latest
|
2019-08-14 18:26:25 -05:00
|
|
|
|
|
|
|
.PHONY: binary-stacker
|
|
|
|
binary-stacker:
|
2020-11-05 20:57:06 -05:00
|
|
|
sudo ${STACKER} build --substitute PWD=$$PWD
|
2020-01-24 12:54:38 -05:00
|
|
|
|
|
|
|
.PHONY: image
|
|
|
|
image:
|
|
|
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile -t zot:latest .
|