From dc93d9469fe6d90d60aebf70f2e08e9e4742bb64 Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Fri, 14 May 2021 16:10:41 -0700 Subject: [PATCH 1/2] interop/xds: dockerfile for the xds interop client --- interop/xds/client/Dockerfile | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 interop/xds/client/Dockerfile diff --git a/interop/xds/client/Dockerfile b/interop/xds/client/Dockerfile new file mode 100644 index 000000000000..98a306e18cac --- /dev/null +++ b/interop/xds/client/Dockerfile @@ -0,0 +1,36 @@ +# Copyright 2020 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Dockerfile for building the xDS interop client. To build the image, run the +# following command from grpc-go directory: +# docker build -t -f interop/xds/client/Dockerfile . + +FROM golang:1.16-alpine as build + +# Make a grpc-go directory and copy the repo into it. +RUN mkdir /go/src/grpc-go +WORKDIR /go/src/grpc-go +COPY . . + +# Build a static binary without cgo so that we can copy just the binary in the +# final image, and can get rid of Go compiler and gRPC-Go dependencies. +WORKDIR /go/src/grpc-go/interop/xds/client +RUN go build -tags osusergo,netgo client.go + +# Second stage of the build which copies over only the client binary and skips +# the Go compiler and gRPC repo from the earlier stage. This significantly +# reduces the docker image size. +FROM alpine +COPY --from=build /go/src/grpc-go/interop/xds/client/client . +ENTRYPOINT ["./client"] From 7141348bac05aa96a7e40a75b56fb584570ebc39 Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Mon, 17 May 2021 12:18:04 -0700 Subject: [PATCH 2/2] review comments. --- interop/xds/client/Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/interop/xds/client/Dockerfile b/interop/xds/client/Dockerfile index 98a306e18cac..060f8a8c64aa 100644 --- a/interop/xds/client/Dockerfile +++ b/interop/xds/client/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2020 gRPC authors. +# Copyright 2021 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,18 +19,16 @@ FROM golang:1.16-alpine as build # Make a grpc-go directory and copy the repo into it. -RUN mkdir /go/src/grpc-go WORKDIR /go/src/grpc-go COPY . . # Build a static binary without cgo so that we can copy just the binary in the # final image, and can get rid of Go compiler and gRPC-Go dependencies. -WORKDIR /go/src/grpc-go/interop/xds/client -RUN go build -tags osusergo,netgo client.go +RUN go build -tags osusergo,netgo interop/xds/client/client.go # Second stage of the build which copies over only the client binary and skips # the Go compiler and gRPC repo from the earlier stage. This significantly # reduces the docker image size. FROM alpine -COPY --from=build /go/src/grpc-go/interop/xds/client/client . +COPY --from=build /go/src/grpc-go/client . ENTRYPOINT ["./client"]