From 4cad71188f58f523656fc025225334e15223d72f Mon Sep 17 00:00:00 2001 From: Rafal Skolasinski Date: Thu, 27 Aug 2020 13:52:21 +0100 Subject: [PATCH 1/2] use copy of operator instead of symlink to keep docker build context local --- executor/.gitignore | 1 + executor/Dockerfile.executor | 22 +++++++++++----------- executor/Dockerfile.executor.redhat | 22 +++++++++++----------- executor/Makefile | 17 ++++++++++++----- executor/go.mod | 2 +- executor/operator | 1 - 6 files changed, 36 insertions(+), 29 deletions(-) delete mode 120000 executor/operator diff --git a/executor/.gitignore b/executor/.gitignore index 8e6b2282e7..d2fd3f4024 100644 --- a/executor/.gitignore +++ b/executor/.gitignore @@ -8,3 +8,4 @@ cover.out executor.tar openapi/ executor/api/rest/openapi/ +_operator diff --git a/executor/Dockerfile.executor b/executor/Dockerfile.executor index 3d83e7e59e..ce677f4614 100644 --- a/executor/Dockerfile.executor +++ b/executor/Dockerfile.executor @@ -3,20 +3,20 @@ FROM golang:1.13 as builder WORKDIR /workspace # Copy the Go Modules manifests -COPY executor/go.mod go.mod -COPY executor/go.sum go.sum -COPY executor/proto/ proto/ +COPY go.mod go.mod +COPY go.sum go.sum +COPY proto/ proto/ # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer -COPY executor/operator/ operator/ +COPY _operator/ _operator/ RUN go mod download # Copy the go source -COPY executor/cmd/ cmd/ -COPY executor/api/ api/ -COPY executor/predictor/ predictor/ -COPY executor/logger/ logger/ -COPY executor/k8s/ k8s/ +COPY cmd/ cmd/ +COPY api/ api/ +COPY predictor/ predictor/ +COPY logger/ logger/ +COPY k8s/ k8s/ # Build RUN go build -a -o executor cmd/executor/main.go @@ -27,7 +27,7 @@ RUN wget -O armon-consul-api.tar.gz https://github.com/armon/consul-api/archive/ RUN wget -O hasicorp-hcl.tar.gz https://github.com/hashicorp/hcl/archive/master.tar.gz # Copy OpenAPI folder and change the permissions -COPY executor/api/rest/openapi/ /openapi/ +COPY api/rest/openapi/ /openapi/ RUN chmod -R 660 /openapi/ # Use distroless as minimal base image to package the manager binary @@ -35,7 +35,7 @@ RUN chmod -R 660 /openapi/ FROM gcr.io/distroless/base:latest WORKDIR / COPY --from=builder /workspace/executor . -COPY executor/licenses/license.txt licenses/license.txt +COPY licenses/license.txt licenses/license.txt COPY --from=builder /workspace/hashicorp-golang-lru.tar.gz licenses/mpl_source/hashicorp-golang-lru.tar.gz COPY --from=builder /workspace/armon-consul-api.tar.gz licenses/mpl_source/armon-consul-api.tar.gz COPY --from=builder /workspace/hasicorp-hcl.tar.gz licenses/mpl_source/hasicorp-hcl.tar.gz diff --git a/executor/Dockerfile.executor.redhat b/executor/Dockerfile.executor.redhat index 6d3f26bd69..be9d1548a6 100644 --- a/executor/Dockerfile.executor.redhat +++ b/executor/Dockerfile.executor.redhat @@ -3,20 +3,20 @@ FROM golang:1.13 as builder WORKDIR /workspace # Copy the Go Modules manifests -COPY executor/go.mod go.mod -COPY executor/go.sum go.sum -COPY executor/proto/ proto/ +COPY go.mod go.mod +COPY go.sum go.sum +COPY proto/ proto/ # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer -COPY executor/operator/ operator/ +COPY _operator/ _operator/ RUN go mod download # Copy the go source -COPY executor/cmd/ cmd/ -COPY executor/api/ api/ -COPY executor/predictor/ predictor/ -COPY executor/logger/ logger/ -COPY executor/k8s/ k8s/ +COPY cmd/ cmd/ +COPY api/ api/ +COPY predictor/ predictor/ +COPY logger/ logger/ +COPY k8s/ k8s/ # Build RUN go build -a -o executor cmd/executor/main.go @@ -27,7 +27,7 @@ RUN wget -O armon-consul-api.tar.gz https://github.com/armon/consul-api/archive/ RUN wget -O hasicorp-hcl.tar.gz https://github.com/hashicorp/hcl/archive/master.tar.gz # Copy OpenAPI folder and change the permissions -COPY executor/api/rest/openapi/ /openapi/ +COPY api/rest/openapi/ /openapi/ RUN chmod -R 660 /openapi/ FROM registry.access.redhat.com/ubi7/ubi @@ -40,7 +40,7 @@ LABEL name="Seldon Executor" \ WORKDIR / COPY --from=builder /workspace/executor . -COPY executor/licenses/license.txt licenses/license.txt +COPY licenses/license.txt licenses/license.txt COPY --from=builder /workspace/hashicorp-golang-lru.tar.gz licenses/mpl_source/hashicorp-golang-lru.tar.gz COPY --from=builder /workspace/armon-consul-api.tar.gz licenses/mpl_source/armon-consul-api.tar.gz COPY --from=builder /workspace/hasicorp-hcl.tar.gz licenses/mpl_source/hasicorp-hcl.tar.gz diff --git a/executor/Makefile b/executor/Makefile index a616f66d70..2bb89be7e7 100644 --- a/executor/Makefile +++ b/executor/Makefile @@ -27,13 +27,20 @@ vet: # Build manager binary -executor: fmt vet +executor: copy_operator fmt vet go build -o executor cmd/executor/main.go -kafka-proxy: fmt vet + +kafka-proxy: copy_operator fmt vet go build -o kafka-proxy cmd/proxy/main.go +.PHONE: copy_operator +copy_operator: + rm _operator -rf + cp -r ../operator _operator + + .PHONY: copy_protos copy_protos: cp -r ../proto/tensorflow/tensorflow/** proto/tensorflow @@ -62,7 +69,7 @@ add_protos: cd serving && find ./tensorflow_serving -name '*.proto' | cpio -pdm ../proto # Run tests -test: fmt vet +test: copy_operator fmt vet go test ${EXECUTOR_FOLDERS} -coverprofile cover.out copy_openapi_resources: @@ -72,11 +79,11 @@ copy_openapi_resources: # Build the docker image docker-build: test copy_openapi_resources - cd .. && docker build -f executor/Dockerfile.executor -t ${IMG} . + docker build -f Dockerfile.executor -t ${IMG} . # Build the docker image for Redhat docker-build-redhat: test copy_openapi_resources - cd .. && docker build -f executor/Dockerfile.executor.redhat -t ${IMG_REDHAT} . + docker build -f Dockerfile.executor.redhat -t ${IMG_REDHAT} . # Push the docker image docker-push: diff --git a/executor/go.mod b/executor/go.mod index 0a53f82150..d7f6587d61 100644 --- a/executor/go.mod +++ b/executor/go.mod @@ -30,4 +30,4 @@ require ( replace github.com/tensorflow/tensorflow/tensorflow/go/core => ./proto/tensorflow/core -replace github.com/seldonio/seldon-core/operator => ./operator +replace github.com/seldonio/seldon-core/operator => ./_operator diff --git a/executor/operator b/executor/operator deleted file mode 120000 index 9410e973dd..0000000000 --- a/executor/operator +++ /dev/null @@ -1 +0,0 @@ -../operator \ No newline at end of file From 733c6830acd550a23891ae604c19de6d9d845003 Mon Sep 17 00:00:00 2001 From: Rafal Skolasinski Date: Tue, 1 Sep 2020 10:23:15 +0100 Subject: [PATCH 2/2] copy operator before generating licences --- executor/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/Makefile b/executor/Makefile index 2bb89be7e7..326ce85fa5 100644 --- a/executor/Makefile +++ b/executor/Makefile @@ -140,7 +140,7 @@ licenses: licenses/dep.txt .PHONY: lint -lint: licenses/dep.txt +lint: copy_operator licenses/dep.txt # Check if licenses have changed git \ --no-pager diff \