0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

build: support building inside a container

This commit is contained in:
Ramkumar Chinchani 2019-08-14 12:35:51 -07:00
parent 735e8589f7
commit 2a96e73384
3 changed files with 39 additions and 5 deletions

7
Dockerfile Normal file
View file

@ -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

View file

@ -1,5 +1,7 @@
export GO111MODULE=on export GO111MODULE=on
TOP_LEVEL=$(shell git rev-parse --show-toplevel) TOP_LEVEL=$(shell git rev-parse --show-toplevel)
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
PATH := bin:$(PATH)
.PHONY: all .PHONY: all
all: doc binary debug test check all: doc binary debug test check
@ -17,12 +19,10 @@ test:
$(shell cd test/data; ./gen_certs.sh; cd ${TOP_LEVEL}) $(shell cd test/data; ./gen_certs.sh; cd ${TOP_LEVEL})
go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./... 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 .PHONY: check
check: ./bin/golangci-lint check:
./bin/golangci-lint run --enable-all ./cmd/... ./pkg/... 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 .PHONY: doc
doc: doc:
@ -36,3 +36,9 @@ clean:
.PHONY: run .PHONY: run
run: binary test run: binary test
./bin/zot serve examples/config-test.json ./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

View file

@ -9,6 +9,27 @@
* *Basic* and TLS mutual authentication * *Basic* and TLS mutual authentication
* Swagger based documentation * 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 _<config>_
# Caveats # Caveats
* go 1.12+ * go 1.12+