diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1ca38a47 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM golang:1.12.8 + +RUN go version +ENV GO111MODULE on +RUN go get -u github.com/swaggo/swag/cmd/swag +WORKDIR /go/src/github.com/anuvu/zot +RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1 diff --git a/Makefile b/Makefile index 065dd986..b5d51b27 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ export GO111MODULE=on TOP_LEVEL=$(shell git rev-parse --show-toplevel) +CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker) +PATH := bin:$(PATH) .PHONY: all all: doc binary debug test check @@ -17,12 +19,10 @@ test: $(shell cd test/data; ./gen_certs.sh; cd ${TOP_LEVEL}) go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./... -./bin/golangci-lint: - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1 - .PHONY: check -check: ./bin/golangci-lint - ./bin/golangci-lint run --enable-all ./cmd/... ./pkg/... +check: + golangci-lint --version || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1 + golangci-lint run --enable-all ./cmd/... ./pkg/... .PHONY: doc doc: @@ -36,3 +36,9 @@ clean: .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:latest . + ${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/anuvu/zot \ + zot:latest make diff --git a/README.md b/README.md index 1f198064..12e4cf37 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,27 @@ * *Basic* and TLS mutual authentication * Swagger based documentation +# Building + +* Build inside a container (preferred) + +``` +make binary-container +``` + +* Build using host's toolchain + +``` +make + +``` + +Build artifacts are in bin/ + +# Running + +bin/zot serve __ + # Caveats * go 1.12+