Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise building workflow of ci and dev containers #922

Merged
merged 4 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
rinx marked this conversation as resolved.
Show resolved Hide resolved
| sh -s -- -b /usr/local/bin ${GOLANGCI_LINT_VERSION}
RUN curl -sSfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh \
rinx marked this conversation as resolved.
Show resolved Hide resolved
| 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}