Skip to content

Commit

Permalink
use copy of operator instead of symlink to keep docker build context …
Browse files Browse the repository at this point in the history
…local
  • Loading branch information
RafalSkolasinski committed Sep 1, 2020
1 parent 70f6f38 commit 4cad711
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
1 change: 1 addition & 0 deletions executor/.gitignore
Expand Up @@ -8,3 +8,4 @@ cover.out
executor.tar
openapi/
executor/api/rest/openapi/
_operator
22 changes: 11 additions & 11 deletions executor/Dockerfile.executor
Expand Up @@ -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
Expand All @@ -27,15 +27,15 @@ 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
# Refer to https://github.com/GoogleContainerTools/distroless for more details
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
Expand Down
22 changes: 11 additions & 11 deletions executor/Dockerfile.executor.redhat
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
17 changes: 12 additions & 5 deletions executor/Makefile
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion executor/go.mod
Expand Up @@ -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
1 change: 0 additions & 1 deletion executor/operator

This file was deleted.

0 comments on commit 4cad711

Please sign in to comment.