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

build: Add containerized make commands. Resolves #6519 #6618

Closed
wants to merge 11 commits into from
Closed
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 .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ assets
community
coverage.out
dist
docs
examples
manifests
sdks
test/e2e
ui/dist
ui/node_modules
v3
vendor
vendor
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ git-ask-pass.sh
/.brew_home
/go-diagrams/
/.run/
.docker-sync
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ scan-%:
.PHONY: codegen
codegen: types swagger docs manifests

.PHONY: codegen-container
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

Expand Down
7 changes: 7 additions & 0 deletions docker-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "2"
syncs:
tooling-sync:
src: ./

options:
compose-file-path: ./hack/docker-compose.tooling.yaml
33 changes: 33 additions & 0 deletions hack/Dockerfile-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 .
COPY go.sum .
RUN go mod download

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
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
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.0
5 changes: 5 additions & 0 deletions hack/docker-compose.tooling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: '3'
services:
tooling:
image: argo-wf-tools
command: make codegen
52 changes: 52 additions & 0 deletions hack/makecmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

build_tools_image() {
docker build -t argo-wf-tools -f ./hack/Dockerfile-tools .
}

start_sync() {
docker-sync start
}

start_sync_stack() {
docker-sync-stack start
}

stop_sync() {
docker-sync stop
}

prune_docker_images() {
docker image prune -f
}

prune_docker_containers() {
docker container prune -f
}

ensure_vendor() {
go mod vendor
}

for arg in "$@"
do
case $arg in
tools-image)
ensure_vendor
build_tools_image
;;
codegen)
ensure_vendor
build_tools_image
start_sync
start_sync_stack
stop_sync
prune_docker_containers
prune_docker_images
;;
prune)
prune_docker_containers
prune_docker_images
;;
esac
done