FROM public.ecr.aws/amazonlinux/amazonlinux:2 AS builder RUN yum update -y && \ yum install -y ca-certificates unzip tar gzip git && \ yum clean all && \ rm -rf /var/cache/yum RUN curl -LO https://go.dev/dl/go1.17.1.linux-amd64.tar.gz && \ tar -C /usr/local -xzvf go1.17.1.linux-amd64.tar.gz ENV PATH="${PATH}:/usr/local/go/bin" ENV GOPATH="${HOME}/go" ENV PATH="${PATH}:${GOPATH}/bin" # Use the default go proxy ARG GO_PROXY=https://goproxy.io WORKDIR /go/src/github.com/aws/github.com/aws-samples/app-mesh-workshop-greater-china/howto-grpc/color_server # Set the proxies for the go compiler. ENV GOPROXY=$GO_PROXY # go.mod and go.sum go into their own layers. # This ensures `go mod download` happens only when go.mod and go.sum change. COPY go.mod . COPY go.sum . RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /color_server . FROM public.ecr.aws/amazonlinux/amazonlinux:2 RUN yum update -y && \ yum install -y ca-certificates && \ yum clean all && \ rm -rf /var/cache/yum COPY --from=builder /color_server /color_server ENTRYPOINT ["/color_server"]