From e90e94cf58ced9ea2c0a2aa5559c8aeb750b4480 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Fri, 27 Aug 2021 12:11:51 -0700 Subject: [PATCH 01/11] build: Add tooling docker image Signed-off-by: J.P. Zivalich --- hack/Dockerfile-tools | 10 ++++++++++ hack/makecmd.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 hack/Dockerfile-tools create mode 100755 hack/makecmd.sh diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools new file mode 100644 index 000000000000..3ef6b3ad2b25 --- /dev/null +++ b/hack/Dockerfile-tools @@ -0,0 +1,10 @@ +FROM golang:1.16-alpine + +RUN apk add make + +WORKDIR /go/src/github.com/argoproj/argo-workflows +COPY go.mod . +COPY go.sum . +RUN go mod download + +COPY . . diff --git a/hack/makecmd.sh b/hack/makecmd.sh new file mode 100755 index 000000000000..469d8da56d39 --- /dev/null +++ b/hack/makecmd.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +build_tools_image() { + docker build -t argo-wf-tools -f ./hack/Dockerfile-tools . +} + +run_mounted_command() { + docker run \ + -it \ + --mount type=bind,source="$(pwd)",target=/go/src/github.com/argoproj/argo-workflows \ + argo-wf-tools \ + "$@" +} + +prune_docker_images() { + docker image prune -f +} + +prune_docker_containers() { + docker container prune -f +} + +for arg in "$@" +do + case $arg in + tools-image) + build_tools_image + ;; + run-cmd) + build_tools_image + run_mounted_command make codegen + prune_docker_containers + prune_docker_images + ;; + prune) + prune_docker_containers + prune_docker_images + ;; + esac +done From e46441150340434641b9ac3be461d37e77002ce1 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Fri, 27 Aug 2021 13:01:56 -0700 Subject: [PATCH 02/11] Fix missing dependencies Signed-off-by: J.P. Zivalich --- Makefile | 3 +++ hack/Dockerfile-tools | 2 +- hack/makecmd.sh | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 425a59fd89be..bfd6a3fe208d 100644 --- a/Makefile +++ b/Makefile @@ -234,6 +234,9 @@ scan-%: .PHONY: codegen codegen: types swagger docs manifests +.PHONY: codegen-container +codegen-container: ./hack/makecmd codegen + .PHONY: types types: pkg/apis/workflow/v1alpha1/generated.proto pkg/apis/workflow/v1alpha1/openapi_generated.go pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index 3ef6b3ad2b25..6e7ac677216b 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -1,6 +1,6 @@ FROM golang:1.16-alpine -RUN apk add make +RUN apk add make bash git WORKDIR /go/src/github.com/argoproj/argo-workflows COPY go.mod . diff --git a/hack/makecmd.sh b/hack/makecmd.sh index 469d8da56d39..9d4b7f98646d 100755 --- a/hack/makecmd.sh +++ b/hack/makecmd.sh @@ -26,7 +26,7 @@ do tools-image) build_tools_image ;; - run-cmd) + codegen) build_tools_image run_mounted_command make codegen prune_docker_containers From bb202c31df987c0b52a80e8e1fac2a427dde2f59 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Fri, 27 Aug 2021 13:12:09 -0700 Subject: [PATCH 03/11] Add protoc and fix makefile Signed-off-by: J.P. Zivalich --- Makefile | 3 ++- hack/Dockerfile-tools | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bfd6a3fe208d..31a395873317 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,8 @@ scan-%: codegen: types swagger docs manifests .PHONY: codegen-container -codegen-container: ./hack/makecmd codegen +codegen-container: + ./hack/makecmd.sh codegen .PHONY: types types: pkg/apis/workflow/v1alpha1/generated.proto pkg/apis/workflow/v1alpha1/openapi_generated.go pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index 6e7ac677216b..731acdafce68 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -1,6 +1,6 @@ FROM golang:1.16-alpine -RUN apk add make bash git +RUN apk add make bash git protoc WORKDIR /go/src/github.com/argoproj/argo-workflows COPY go.mod . From 2489b019bdea18b18d7ad05b31b259b1425e893c Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Fri, 27 Aug 2021 14:33:53 -0700 Subject: [PATCH 04/11] Install go packages in dockerfile Signed-off-by: J.P. Zivalich --- hack/Dockerfile-tools | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index 731acdafce68..75372458881c 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -8,3 +8,12 @@ COPY go.sum . RUN go mod download COPY . . + +RUN go mod vendor + +RUN go install -mod=vendor ./vendor/k8s.io/code-generator/cmd/go-to-protobuf +RUN go install -mod=vendor ./vendor/github.com/gogo/protobuf/protoc-gen-gogo +RUN go install -mod=vendor ./vendor/github.com/gogo/protobuf/protoc-gen-gogofast +RUN go install -mod=vendor ./vendor/golang.org/x/tools/cmd/goimports +RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway +RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger From ac1f5bd5e5215f5edeb006a8b7555adf0309ab16 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Fri, 27 Aug 2021 15:13:06 -0700 Subject: [PATCH 05/11] Add in missing dependencies Signed-off-by: J.P. Zivalich --- hack/Dockerfile-tools | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index 75372458881c..2b6ecd49e447 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -1,6 +1,6 @@ FROM golang:1.16-alpine -RUN apk add make bash git protoc +RUN apk add make bash git protoc protobuf-dev perl WORKDIR /go/src/github.com/argoproj/argo-workflows COPY go.mod . @@ -17,3 +17,4 @@ RUN go install -mod=vendor ./vendor/github.com/gogo/protobuf/protoc-gen-gogofast RUN go install -mod=vendor ./vendor/golang.org/x/tools/cmd/goimports RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger +RUN go install -mod=vendor ./vendor/k8s.io/kube-openapi/cmd/openapi-gen From 3cac958b3892c8ec52bbdf706654d8076ee51133 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Fri, 27 Aug 2021 16:22:14 -0700 Subject: [PATCH 06/11] Add kubectl dependency Signed-off-by: J.P. Zivalich --- hack/Dockerfile-tools | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index 2b6ecd49e447..0ea268128f60 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -1,7 +1,12 @@ FROM golang:1.16-alpine -RUN apk add make bash git protoc protobuf-dev perl +RUN apk add make bash git protoc protobuf-dev perl curl +# install kubectl +RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" +RUN chmod u+x kubectl && mv kubectl /bin/kubectl + +# cache mod dependencies WORKDIR /go/src/github.com/argoproj/argo-workflows COPY go.mod . COPY go.sum . @@ -11,6 +16,7 @@ COPY . . RUN go mod vendor +# install go binaries in dockerfile - faster than at runtime RUN go install -mod=vendor ./vendor/k8s.io/code-generator/cmd/go-to-protobuf RUN go install -mod=vendor ./vendor/github.com/gogo/protobuf/protoc-gen-gogo RUN go install -mod=vendor ./vendor/github.com/gogo/protobuf/protoc-gen-gogofast @@ -18,3 +24,4 @@ RUN go install -mod=vendor ./vendor/golang.org/x/tools/cmd/goimports RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger RUN go install -mod=vendor ./vendor/k8s.io/kube-openapi/cmd/openapi-gen +RUN go install -mod=vendor ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen From 5e71d3aa79561f50ef82a2732f5d49a199001a59 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Sat, 28 Aug 2021 22:30:23 -0700 Subject: [PATCH 07/11] Fix busybox grep error Signed-off-by: J.P. Zivalich --- hack/Dockerfile-tools | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index 0ea268128f60..e72ead4e285e 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -1,6 +1,8 @@ FROM golang:1.16-alpine -RUN apk add make bash git protoc protobuf-dev perl curl +# upgrade grep fixes alpine busybox error +RUN apk add make bash git protoc protobuf-dev perl curl \ + && apk add --no-cache --upgrade grep # install kubectl RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" From b12948fcb39056af182bd2b13b1b5d1de2b68ab9 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Sun, 29 Aug 2021 10:01:56 -0700 Subject: [PATCH 08/11] Ensure vendor directory Signed-off-by: J.P. Zivalich --- hack/makecmd.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hack/makecmd.sh b/hack/makecmd.sh index 9d4b7f98646d..a38244a0981a 100755 --- a/hack/makecmd.sh +++ b/hack/makecmd.sh @@ -20,6 +20,10 @@ prune_docker_containers() { docker container prune -f } +ensure_vendor() { + go mod vendor +} + for arg in "$@" do case $arg in @@ -27,6 +31,7 @@ do build_tools_image ;; codegen) + ensure_vendor build_tools_image run_mounted_command make codegen prune_docker_containers From 6f8ed4b3b1061bc450326d2075908a8cbf9daa84 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Mon, 30 Aug 2021 09:03:58 -0700 Subject: [PATCH 09/11] Ensure vendor and start lint command Signed-off-by: J.P. Zivalich --- hack/makecmd.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hack/makecmd.sh b/hack/makecmd.sh index a38244a0981a..2cfb065141b0 100755 --- a/hack/makecmd.sh +++ b/hack/makecmd.sh @@ -28,6 +28,7 @@ for arg in "$@" do case $arg in tools-image) + ensure_vendor build_tools_image ;; codegen) @@ -37,6 +38,13 @@ do prune_docker_containers prune_docker_images ;; + lint) + ensure_vendor + build_tools_image + run_mounted_command make lint + prune_docker_containers + prune_docker_images + ;; prune) prune_docker_containers prune_docker_images From b60e0dbc6ee0a3d1f371afd8950db50263d86488 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Sat, 4 Sep 2021 14:47:50 -0700 Subject: [PATCH 10/11] Change cgo for dockerfile Signed-off-by: J.P. Zivalich --- hack/Dockerfile-tools | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hack/Dockerfile-tools b/hack/Dockerfile-tools index e72ead4e285e..7ccb24cdd291 100644 --- a/hack/Dockerfile-tools +++ b/hack/Dockerfile-tools @@ -2,12 +2,15 @@ FROM golang:1.16-alpine # upgrade grep fixes alpine busybox error RUN apk add make bash git protoc protobuf-dev perl curl \ + gcc musl-dev git mercurial \ && apk add --no-cache --upgrade grep # install kubectl RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" RUN chmod u+x kubectl && mv kubectl /bin/kubectl +ENV CGO_ENABLED=0 + # cache mod dependencies WORKDIR /go/src/github.com/argoproj/argo-workflows COPY go.mod . @@ -27,3 +30,4 @@ RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/proto RUN go install -mod=vendor ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger RUN go install -mod=vendor ./vendor/k8s.io/kube-openapi/cmd/openapi-gen RUN go install -mod=vendor ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.0 From caf62caa3339ae126b2941a10b274dcf002e8441 Mon Sep 17 00:00:00 2001 From: "J.P. Zivalich" Date: Sun, 5 Sep 2021 00:43:11 -0700 Subject: [PATCH 11/11] Switch to docker-sync Signed-off-by: J.P. Zivalich --- .dockerignore | 4 +--- .gitignore | 1 + docker-sync.yml | 7 +++++++ hack/docker-compose.tooling.yaml | 5 +++++ hack/makecmd.sh | 27 +++++++++++++-------------- 5 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 docker-sync.yml create mode 100644 hack/docker-compose.tooling.yaml diff --git a/.dockerignore b/.dockerignore index f4ecf7c80b03..5787ae7b80f7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,12 +10,10 @@ assets community coverage.out dist -docs examples -manifests sdks test/e2e ui/dist ui/node_modules v3 -vendor \ No newline at end of file +vendor diff --git a/.gitignore b/.gitignore index e93a509b5056..b738bc6673f4 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ git-ask-pass.sh /.brew_home /go-diagrams/ /.run/ +.docker-sync diff --git a/docker-sync.yml b/docker-sync.yml new file mode 100644 index 000000000000..0bde21c48502 --- /dev/null +++ b/docker-sync.yml @@ -0,0 +1,7 @@ +version: "2" +syncs: + tooling-sync: + src: ./ + +options: + compose-file-path: ./hack/docker-compose.tooling.yaml diff --git a/hack/docker-compose.tooling.yaml b/hack/docker-compose.tooling.yaml new file mode 100644 index 000000000000..33fb4ca50cf4 --- /dev/null +++ b/hack/docker-compose.tooling.yaml @@ -0,0 +1,5 @@ +version: '3' +services: + tooling: + image: argo-wf-tools + command: make codegen diff --git a/hack/makecmd.sh b/hack/makecmd.sh index 2cfb065141b0..1cf62bbb05f2 100755 --- a/hack/makecmd.sh +++ b/hack/makecmd.sh @@ -4,12 +4,16 @@ build_tools_image() { docker build -t argo-wf-tools -f ./hack/Dockerfile-tools . } -run_mounted_command() { - docker run \ - -it \ - --mount type=bind,source="$(pwd)",target=/go/src/github.com/argoproj/argo-workflows \ - argo-wf-tools \ - "$@" +start_sync() { + docker-sync start +} + +start_sync_stack() { + docker-sync-stack start +} + +stop_sync() { + docker-sync stop } prune_docker_images() { @@ -34,14 +38,9 @@ do codegen) ensure_vendor build_tools_image - run_mounted_command make codegen - prune_docker_containers - prune_docker_images - ;; - lint) - ensure_vendor - build_tools_image - run_mounted_command make lint + start_sync + start_sync_stack + stop_sync prune_docker_containers prune_docker_images ;;