From 3f660e28238b9bbb5640fb7ce9ff651dd7597252 Mon Sep 17 00:00:00 2001 From: Rintaro Okamura Date: Thu, 14 Jan 2021 11:24:06 +0900 Subject: [PATCH 1/3] :green_heart: Fix prettier/install task to work correctly Signed-off-by: Rintaro Okamura --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 83f837a54e..8216a53bd1 100644 --- a/Makefile +++ b/Makefile @@ -362,9 +362,7 @@ goimports/install: .PHONY: prettier/install prettier/install: - if !type prettier >/dev/null 2>&1; then \ - npm install -g npm prettier; \ - fi + type prettier || npm install -g prettier .PHONY: version/vald ## print vald version From be498f57886b550c68f1ad8ca17c8c6be8840aed Mon Sep 17 00:00:00 2001 From: Rintaro Okamura Date: Thu, 14 Jan 2021 11:46:08 +0900 Subject: [PATCH 2/3] :hammer: Split CI container and dev container Signed-off-by: Rintaro Okamura --- Makefile.d/docker.mk | 5 ++--- dockers/ci/base/Dockerfile | 10 ++++++---- dockers/dev/Dockerfile | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/Makefile.d/docker.mk b/Makefile.d/docker.mk index ac44490ff1..05db7b1dcf 100644 --- a/Makefile.d/docker.mk +++ b/Makefile.d/docker.mk @@ -288,13 +288,12 @@ docker/name/dev-container: .PHONY: docker/build/dev-container ## build dev-container image -docker/build/dev-container: docker/build/ci-container +docker/build/dev-container: $(DOCKER) build \ $(DOCKER_OPTS) \ -f dockers/dev/Dockerfile \ -t $(ORG)/$(DEV_CONTAINER_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg BASE_TAG=$(TAG) + --build-arg MAINTAINER=$(MAINTAINER) .PHONY: docker/name/operator/helm docker/name/operator/helm: diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index 7c10f25aae..3d5eba60e9 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -16,14 +16,16 @@ ARG GO_VERSION=latest ARG BASE_TAG=latest +ARG MAINTAINER="vdaas.org vald team " FROM golang:${GO_VERSION} AS golang FROM vdaas/vald-base:${BASE_TAG} AS builder -ARG PROTOBUF_VERSION=3.13.0 -ARG GOLANGCI_LINT_VERSION=v1.31.0 -ARG REVIEWDOG_VERSION=v0.10.2 -ARG YQ_VERSION=3.3.4 +ARG PROTOBUF_VERSION=3.14.0 +ARG GOLANGCI_LINT_VERSION=v1.35.2 +ARG REVIEWDOG_VERSION=v0.11.0 +ARG YQ_VERSION=4.3.2 +LABEL maintainer "${MAINTAINER}" COPY --from=golang /usr/local/go $GOROOT diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index f6abae1848..31a4088605 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -15,9 +15,31 @@ # ARG BASE_TAG=latest -ARG MAINTAINER="vdaas.org vald team +ARG MAINTAINER="vdaas.org vald team " -FROM vdaas/vald-ci-container:${BASE_TAG} AS vald +FROM vdaas/vald-base:${BASE_TAG} AS builder +ARG PROTOBUF_VERSION=3.14.0 +ARG GOLANGCI_LINT_VERSION=v1.35.2 +ARG REVIEWDOG_VERSION=v0.11.0 +ARG YQ_VERSION=4.3.2 + +RUN cd /tmp \ + && curl -OL "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" \ + && unzip protoc-${PROTOBUF_VERSION}-linux-x86_64.zip -d protoc3 \ + && mv protoc3/bin/* /usr/local/bin/ \ + && mv protoc3/include/* /usr/local/include/ \ + && rm -rf protoc-${PROTOBUF_VERSION}-linux-x86_64.zip protoc3 + +RUN curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ + && chmod a+x /usr/local/bin/kubectl + +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ + | sh -s -- -b /usr/local/bin ${GOLANGCI_LINT_VERSION} +RUN curl -sSfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \ + | sh -s -- -b /usr/local/bin ${REVIEWDOG_VERSION} + +RUN curl -Lo /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 \ + && chmod a+x /usr/local/bin/yq FROM mcr.microsoft.com/vscode/devcontainers/go:1 AS base LABEL maintainer "${MAINTAINER}" @@ -55,12 +77,12 @@ RUN make helm-docs/install RUN make kind/install RUN make valdcli/install -COPY --from=vald /usr/local/bin/protoc /usr/local/bin/protoc -COPY --from=vald /usr/local/include/google /usr/local/include/google +COPY --from=builder /usr/local/bin/protoc /usr/local/bin/protoc +COPY --from=builder /usr/local/include/google /usr/local/include/google -COPY --from=vald /usr/local/bin/kubectl /usr/local/bin/kubectl -COPY --from=vald /usr/local/bin/yq /usr/local/bin/yq -COPY --from=vald ${GOPATH}/bin/golangci-lint ${GOPATH}/bin/golangci-lint -COPY --from=vald ${GOPATH}/bin/reviewdog ${GOPATH}/bin/reviewdog +COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl +COPY --from=builder /usr/local/bin/yq /usr/local/bin/yq +COPY --from=builder /usr/local/bin/golangci-lint /usr/local/bin/golangci-lint +COPY --from=builder /usr/local/bin/reviewdog /usr/local/bin/reviewdog WORKDIR ${GOPATH} From c25dd4d768f370d1ab33bbf2f774f8aa9ae789bd Mon Sep 17 00:00:00 2001 From: Rintaro Okamura Date: Thu, 14 Jan 2021 11:56:00 +0900 Subject: [PATCH 3/3] :rotating_light: fix linter warnings Signed-off-by: Rintaro Okamura --- dockers/ci/base/Dockerfile | 22 +++++++++++----------- dockers/dev/Dockerfile | 7 ++++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index 3d5eba60e9..e926667e4a 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -29,14 +29,6 @@ LABEL maintainer "${MAINTAINER}" COPY --from=golang /usr/local/go $GOROOT -WORKDIR ${GOPATH}/src/github.com/vdaas/vald - -COPY Makefile . -COPY Makefile.d Makefile.d -COPY apis/proto apis/proto -COPY versions versions -COPY hack/go.mod.default hack/go.mod.default - RUN apt-get update && apt-get install -y --no-install-recommends \ libhdf5-dev \ graphviz \ @@ -49,13 +41,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN cd /tmp \ - && curl -OL "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" \ +WORKDIR /tmp +RUN curl -OL "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" \ && unzip protoc-${PROTOBUF_VERSION}-linux-x86_64.zip -d protoc3 \ && mv protoc3/bin/* /usr/local/bin/ \ && mv protoc3/include/* /usr/local/include/ \ && rm -rf protoc-${PROTOBUF_VERSION}-linux-x86_64.zip protoc3 +WORKDIR ${GOPATH}/src/github.com/vdaas/vald + +COPY Makefile . +COPY Makefile.d Makefile.d +COPY apis/proto apis/proto +COPY versions versions +COPY hack/go.mod.default hack/go.mod.default + RUN make deps RUN make ngt/install @@ -68,7 +68,7 @@ RUN make valdcli/install RUN make tparse/install -RUN curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ +RUN curl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl \ && chmod a+x /usr/local/bin/kubectl RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index 31a4088605..6f86d4f68d 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -23,14 +23,15 @@ ARG GOLANGCI_LINT_VERSION=v1.35.2 ARG REVIEWDOG_VERSION=v0.11.0 ARG YQ_VERSION=4.3.2 -RUN cd /tmp \ - && curl -OL "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" \ +WORKDIR /tmp + +RUN curl -OL "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" \ && unzip protoc-${PROTOBUF_VERSION}-linux-x86_64.zip -d protoc3 \ && mv protoc3/bin/* /usr/local/bin/ \ && mv protoc3/include/* /usr/local/include/ \ && rm -rf protoc-${PROTOBUF_VERSION}-linux-x86_64.zip protoc3 -RUN curl -L https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ +RUN curl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl \ && chmod a+x /usr/local/bin/kubectl RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \