Skip to content

Commit 2a96e73

Browse files
author
Ramkumar Chinchani
committed
build: support building inside a container
1 parent 735e858 commit 2a96e73

3 files changed

Lines changed: 39 additions & 5 deletions

File tree

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM golang:1.12.8
2+
3+
RUN go version
4+
ENV GO111MODULE on
5+
RUN go get -u github.com/swaggo/swag/cmd/swag
6+
WORKDIR /go/src/github.com/anuvu/zot
7+
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export GO111MODULE=on
22
TOP_LEVEL=$(shell git rev-parse --show-toplevel)
3+
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
4+
PATH := bin:$(PATH)
35

46
.PHONY: all
57
all: doc binary debug test check
@@ -17,12 +19,10 @@ test:
1719
$(shell cd test/data; ./gen_certs.sh; cd ${TOP_LEVEL})
1820
go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
1921

20-
./bin/golangci-lint:
21-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1
22-
2322
.PHONY: check
24-
check: ./bin/golangci-lint
25-
./bin/golangci-lint run --enable-all ./cmd/... ./pkg/...
23+
check:
24+
golangci-lint --version || curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1
25+
golangci-lint run --enable-all ./cmd/... ./pkg/...
2626

2727
.PHONY: doc
2828
doc:
@@ -36,3 +36,9 @@ clean:
3636
.PHONY: run
3737
run: binary test
3838
./bin/zot serve examples/config-test.json
39+
40+
.PHONY: binary-container
41+
binary-container:
42+
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile -t zot:latest .
43+
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/anuvu/zot \
44+
zot:latest make

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@
99
* *Basic* and TLS mutual authentication
1010
* Swagger based documentation
1111

12+
# Building
13+
14+
* Build inside a container (preferred)
15+
16+
```
17+
make binary-container
18+
```
19+
20+
* Build using host's toolchain
21+
22+
```
23+
make
24+
25+
```
26+
27+
Build artifacts are in bin/
28+
29+
# Running
30+
31+
bin/zot serve _<config>_
32+
1233
# Caveats
1334

1435
* go 1.12+

0 commit comments

Comments
 (0)