From 09c633ad9183e5fd10df7356fa79400a8c25e41e Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Thu, 5 Nov 2020 17:39:14 -0800 Subject: [PATCH 1/3] build: fix docker build Update Dockerfile and Makefile to build a zot docker image --- Dockerfile | 25 +++++++++++++++---------- Dockerfile.build | 7 ------- Makefile | 7 +++++-- 3 files changed, 20 insertions(+), 19 deletions(-) delete mode 100644 Dockerfile.build diff --git a/Dockerfile b/Dockerfile index 6f1a6ae9..73524768 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,23 @@ # --- # Stage 1: Install certs, build binary, create default config file # --- -FROM docker.io/golang:1.13.6-alpine3.11 AS builder -RUN apk --update add git make ca-certificates +FROM docker.io/golang:1.15.3 AS builder RUN mkdir -p /go/src/github.com/anuvu/zot WORKDIR /go/src/github.com/anuvu/zot COPY . . RUN CGO_ENABLED=0 make clean binary -RUN echo -e '# Default config file for zot server\n\ -http:\n\ - address: 0.0.0.0\n\ - port: 5000\n\ -storage:\n\ - rootDirectory: /var/lib/registry' > config.yml && cat config.yml +RUN echo '{\n\ + "storage": {\n\ + "rootDirectory": "/var/lib/registry"\n\ + },\n\ + "http": {\n\ + "address": "0.0.0.0",\n\ + "port": "5000"\n\ + },\n\ + "log": {\n\ + "level": "debug"\n\ + }\n\ +}\n' > config.json && cat config.json # --- # Stage 2: Final image with nothing but certs, binary, and default config file @@ -20,8 +25,8 @@ storage:\n\ FROM scratch AS final COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /go/src/github.com/anuvu/zot/bin/zot /zot -COPY --from=builder /go/src/github.com/anuvu/zot/config.yml /etc/zot/config.yml +COPY --from=builder /go/src/github.com/anuvu/zot/config.json /etc/zot/config.json ENTRYPOINT ["/zot"] EXPOSE 5000 VOLUME ["/var/lib/registry"] -CMD ["serve", "/etc/zot/config.yml"] +CMD ["serve", "/etc/zot/config.json"] diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index 1ca38a47..00000000 --- a/Dockerfile.build +++ /dev/null @@ -1,7 +0,0 @@ -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 876e666b..a448d1e9 100644 --- a/Makefile +++ b/Makefile @@ -52,9 +52,12 @@ run: binary test .PHONY: binary-container binary-container: - ${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f Dockerfile.build -t zot-build:latest . + ${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 make + zot-build:latest .PHONY: binary-stacker binary-stacker: From c5e3431f147ee2ea08d6376053736a0d2eaa7d69 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Thu, 5 Nov 2020 17:57:06 -0800 Subject: [PATCH 2/3] build: fix stacker build --- Makefile | 3 ++- stacker.yaml | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a448d1e9..e541c02d 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ COMMIT=$(if $(shell git status --porcelain --untracked-files=no),$(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: doc binary binary-minimal debug test check @@ -61,7 +62,7 @@ run-container: .PHONY: binary-stacker binary-stacker: - stacker --roots-dir ${TMPDIR} build --substitute PWD=$$PWD + sudo ${STACKER} build --substitute PWD=$$PWD .PHONY: image image: diff --git a/stacker.yaml b/stacker.yaml index c53e874f..833a1c89 100644 --- a/stacker.yaml +++ b/stacker.yaml @@ -1,19 +1,20 @@ build: from: type: docker - url: docker://golang:1.14.4 + url: docker://golang:1.15.3 binds: - - ${{PWD}} -> /go/src/github.com/anuvu/zot + - ${{PWD}} -> /zotcopy run: | export GO111MODULE=on export GOPATH='/go' export HOME='/root' export PATH='/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' go get -u github.com/swaggo/swag/cmd/swag + mkdir -p /go/src/github.com/anuvu + cd /go/src/github.com/anuvu + git clone /zotcopy zot cd /go/src/github.com/anuvu/zot - go get -u -v -d ./... - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.26.0 - make + make binary build_only: true zot: From cb240ffd84d7474c6c87debd7d42d827a2b96b1d Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Wed, 18 Nov 2020 16:22:41 -0800 Subject: [PATCH 3/3] ci/cd: disable bazel builds in travis ci/cd --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0a26fca9..d94a8196 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -N https://github.com/bazelbuild/bazel/releases/download/3.0.0/bazel-3.0.0-installer-linux-x86_64.sh && chmod +x bazel-3.0.0-installer-linux-x86_64.sh && ./bazel-3.0.0-installer-linux-x86_64.sh --user; go get -u github.com/swaggo/swag/cmd/swag; go mod download; sudo apt-get update; sudo apt-get install rpm; sudo apt install snapd; sudo snap install skopeo --edge --devmode; fi script: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_wait 40 make && travis_wait 40 make -f Makefile.bazel build; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_wait 60 make; fi after_success: - bash <(curl -s https://codecov.io/bash)