mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
8e4d828867
Signed-off-by: Alexei Dodon <adodon@cisco.com>
89 lines
4.3 KiB
Makefile
89 lines
4.3 KiB
Makefile
export GO111MODULE=on
|
|
TOP_LEVEL=$(shell git rev-parse --show-toplevel)
|
|
COMMIT_HASH=$(shell git describe --always --tags --long)
|
|
GO_VERSION=$(shell go version | awk '{print $$3}')
|
|
COMMIT=$(if $(shell git status --porcelain --untracked-files=no),$(COMMIT_HASH)-dirty,$(COMMIT_HASH))
|
|
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
|
|
PATH := bin:$(PATH)
|
|
TMPDIR := $(shell mktemp -d)
|
|
STACKER := $(shell which stacker)
|
|
|
|
.PHONY: all
|
|
all: swagger binary binary-minimal exporter-minimal debug test test-clean check
|
|
|
|
.PHONY: binary-minimal
|
|
binary-minimal: swagger
|
|
go build -o bin/zot-minimal -tags minimal,containers_image_openpgp -v -trimpath -ldflags "-X github.com/anuvu/zot/pkg/api/config.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api/config.BinaryType=minimal -X github.com/anuvu/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot
|
|
|
|
.PHONY: binary
|
|
binary: swagger
|
|
go build -o bin/zot -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X github.com/anuvu/zot/pkg/api/config.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api/config.BinaryType=extended -X github.com/anuvu/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot
|
|
|
|
.PHONY: debug
|
|
debug: swagger
|
|
go build -o bin/zot-debug -tags extended,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X github.com/anuvu/zot/pkg/api/config.Commit=${COMMIT} -X github.com/anuvu/zot/pkg/api/config.BinaryType=extended -X github.com/anuvu/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot
|
|
|
|
.PHONY: exporter-minimal
|
|
exporter-minimal: swagger
|
|
go build -o bin/zot-exporter -tags minimal,containers_image_openpgp -v -trimpath ./cmd/exporter
|
|
|
|
.PHONY: test
|
|
test:
|
|
$(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)
|
|
$(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)
|
|
go test -tags extended,containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile=coverage-extended.txt -covermode=atomic ./...
|
|
go test -tags minimal,containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile=coverage-minimal.txt -covermode=atomic ./...
|
|
|
|
.PHONY: test-clean
|
|
test-clean:
|
|
$(shell sudo rm -rf /etc/containers/certs.d/127.0.0.1:8089/)
|
|
|
|
.PHONY: covhtml
|
|
covhtml:
|
|
tail -n +2 coverage-minimal.txt > tmp.txt && mv tmp.txt coverage-minimal.txt
|
|
cat coverage-extended.txt coverage-minimal.txt > coverage.txt
|
|
go tool cover -html=coverage.txt -o coverage.html
|
|
|
|
.PHONY: check
|
|
check: ./golangcilint.yaml
|
|
golangci-lint --version || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.26.0
|
|
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 ./...
|
|
|
|
swagger/docs.go:
|
|
swag -v || go install github.com/swaggo/swag/cmd/swag
|
|
swag init -o swagger -g pkg/api/routes.go
|
|
|
|
.PHONY: swagger
|
|
swagger: swagger/docs.go
|
|
|
|
.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)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f bin/zot*
|
|
|
|
.PHONY: run
|
|
run: binary test
|
|
./bin/zot serve examples/config-test.json
|
|
|
|
.PHONY: binary-container
|
|
binary-container:
|
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile -t zot-build:latest .
|
|
|
|
.PHONY: run-container
|
|
run-container:
|
|
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/anuvu/zot \
|
|
zot-build:latest
|
|
|
|
.PHONY: binary-stacker
|
|
binary-stacker:
|
|
sudo ${STACKER} build --substitute PWD=$$PWD
|
|
|
|
.PHONY: image
|
|
image:
|
|
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile -t zot:latest .
|