Skip to content

Commit

Permalink
Revise building workflow of ci and dev containers (#922)
Browse files Browse the repository at this point in the history
* 💚 Fix prettier/install task to work correctly

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>

* 🔨 Split CI container and dev container

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>

* 🚨 fix linter warnings

Signed-off-by: Rintaro Okamura <rintaro.okamura@gmail.com>

Co-authored-by: Yusuke Kato <kpango@vdaas.org>
  • Loading branch information
rinx and kpango authored Jan 14, 2021
1 parent a43f8f7 commit bfd86f2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions Makefile.d/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 17 additions & 15 deletions dockers/ci/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,19 @@

ARG GO_VERSION=latest
ARG BASE_TAG=latest
ARG MAINTAINER="vdaas.org vald team <vald@vdaas.org>"

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

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 \
Expand All @@ -47,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
Expand All @@ -66,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 \
Expand Down
39 changes: 31 additions & 8 deletions dockers/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,32 @@
#

ARG BASE_TAG=latest
ARG MAINTAINER="vdaas.org vald team <vald@vdaas.org>
ARG MAINTAINER="vdaas.org vald team <vald@vdaas.org>"

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

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 \
&& 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}"
Expand Down Expand Up @@ -55,12 +78,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}

0 comments on commit bfd86f2

Please sign in to comment.