From d55cada373b33f85c1eb943157190793524900e8 Mon Sep 17 00:00:00 2001 From: Mythri Garaga Manjunatha Date: Thu, 22 Oct 2020 09:16:40 -0700 Subject: [PATCH] modify Makefile to use different Golang version while building Agent for Windows --- Makefile | 22 ++++++++++++++----- scripts/dockerfiles/Dockerfile.build | 3 ++- .../dockerfiles/Dockerfile.buildECSCNIPlugins | 3 ++- .../dockerfiles/Dockerfile.buildVPCCNIPlugins | 3 ++- scripts/dockerfiles/Dockerfile.cleanbuild | 3 ++- scripts/dockerfiles/Dockerfile.test | 5 ++++- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b0810e191f9..c781109020b 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,10 @@ gobuild: static: ./scripts/build +# Go versions supported in Agent +GO_VERSION=1.15 +GO_VERSION_WINDOWS=1.12 + # Cross-platform build target for travis xplatform-build: GOOS=linux GOARCH=arm64 ./scripts/build true "" false @@ -47,7 +51,7 @@ xplatform-build: BUILDER_IMAGE="amazon/amazon-ecs-agent-build:make" .builder-image-stamp: scripts/dockerfiles/Dockerfile.build - @docker build -f scripts/dockerfiles/Dockerfile.build -t $(BUILDER_IMAGE) . + @docker build --build-arg GO_VERSION=$(GO_VERSION) -f scripts/dockerfiles/Dockerfile.build -t $(BUILDER_IMAGE) . touch .builder-image-stamp # 'build-in-docker' builds the agent within a dockerfile and saves it to the ./out @@ -71,11 +75,19 @@ docker: certs build-in-docker pause-container-release cni-plugins .out-stamp @docker build -f scripts/dockerfiles/Dockerfile.release -t "amazon/amazon-ecs-agent:make" . @echo "Built Docker image \"amazon/amazon-ecs-agent:make\"" +ifeq (${TARGET_OS},windows) + BUILD="cleanbuild-${TARGET_OS}" + GO_VERSION=${GO_VERSION_WINDOWS} +else + BUILD=cleanbuild + GO_VERSION=${GO_VERSION} +endif + # 'docker-release' builds the agent from a clean snapshot of the git repo in # 'RELEASE' mode # TODO: make this idempotent docker-release: pause-container-release cni-plugins .out-stamp - @docker build -f scripts/dockerfiles/Dockerfile.cleanbuild -t "amazon/amazon-ecs-agent-cleanbuild:make" . + @docker build --build-arg GO_VERSION=${GO_VERSION} -f scripts/dockerfiles/Dockerfile.cleanbuild -t "amazon/amazon-ecs-agent-${BUILD}:make" . @docker run --net=none \ --env TARGET_OS="${TARGET_OS}" \ --env LDFLAGS="-X github.com/aws/amazon-ecs-agent/agent/config.DefaultPauseContainerTag=$(PAUSE_CONTAINER_TAG) \ @@ -84,7 +96,7 @@ docker-release: pause-container-release cni-plugins .out-stamp --volume "$(PWD)/out:/out" \ --volume "$(PWD):/src/amazon-ecs-agent" \ --rm \ - "amazon/amazon-ecs-agent-cleanbuild:make" + "amazon/amazon-ecs-agent-${BUILD}:make" # Release packages our agent into a "scratch" based dockerfile release: certs docker-release @@ -181,7 +193,7 @@ get-cni-sources: git submodule update --init --recursive build-ecs-cni-plugins: - @docker build -f scripts/dockerfiles/Dockerfile.buildECSCNIPlugins -t "amazon/amazon-ecs-build-ecs-cni-plugins:make" . + @docker build --build-arg GO_VERSION=$(GO_VERSION) -f scripts/dockerfiles/Dockerfile.buildECSCNIPlugins -t "amazon/amazon-ecs-build-ecs-cni-plugins:make" . docker run --rm --net=none \ -e GIT_SHORT_HASH=$(shell cd $(ECS_CNI_REPOSITORY_SRC_DIR) && git rev-parse --short=8 HEAD) \ -e GIT_PORCELAIN=$(shell cd $(ECS_CNI_REPOSITORY_SRC_DIR) && git status --porcelain 2> /dev/null | wc -l | sed 's/^ *//') \ @@ -192,7 +204,7 @@ build-ecs-cni-plugins: @echo "Built amazon-ecs-cni-plugins successfully." build-vpc-cni-plugins: - @docker build --build-arg GOARCH=$(GOARCH) -f scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins -t "amazon/amazon-ecs-build-vpc-cni-plugins:make" . + @docker build --build-arg GOARCH=$(GOARCH) --build-arg GO_VERSION=$(GO_VERSION) -f scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins -t "amazon/amazon-ecs-build-vpc-cni-plugins:make" . docker run --rm --net=none \ -e GIT_SHORT_HASH=$(shell cd $(VPC_CNI_REPOSITORY_SRC_DIR) && git rev-parse --short=8 HEAD) \ -u "$(USERID)" \ diff --git a/scripts/dockerfiles/Dockerfile.build b/scripts/dockerfiles/Dockerfile.build index f694d8d5f83..a472b92aaa3 100644 --- a/scripts/dockerfiles/Dockerfile.build +++ b/scripts/dockerfiles/Dockerfile.build @@ -11,7 +11,8 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM golang:1.12 +ARG GO_VERSION=1.15 +FROM golang:${GO_VERSION} MAINTAINER Amazon Web Services, Inc. ENV XDG_CACHE_HOME /tmp diff --git a/scripts/dockerfiles/Dockerfile.buildECSCNIPlugins b/scripts/dockerfiles/Dockerfile.buildECSCNIPlugins index 9af2e0cce41..8eea4754e26 100644 --- a/scripts/dockerfiles/Dockerfile.buildECSCNIPlugins +++ b/scripts/dockerfiles/Dockerfile.buildECSCNIPlugins @@ -11,7 +11,8 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM golang:1.15 +ARG GO_VERSION=1.15 +FROM golang:${GO_VERSION} MAINTAINER Amazon Web Services, Inc. ENV XDG_CACHE_HOME /tmp diff --git a/scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins b/scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins index ecebc01996a..c72554a1e11 100644 --- a/scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins +++ b/scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins @@ -11,7 +11,8 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM golang:1.15 +ARG GO_VERSION=1.15 +FROM golang:${GO_VERSION} MAINTAINER Amazon Web Services, Inc. ARG GOARCH diff --git a/scripts/dockerfiles/Dockerfile.cleanbuild b/scripts/dockerfiles/Dockerfile.cleanbuild index a43a399c436..7e90e1baa40 100644 --- a/scripts/dockerfiles/Dockerfile.cleanbuild +++ b/scripts/dockerfiles/Dockerfile.cleanbuild @@ -11,7 +11,8 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -FROM golang:1.15 +ARG GO_VERSION=1.15 +FROM golang:${GO_VERSION} MAINTAINER Amazon Web Services, Inc. ENV XDG_CACHE_HOME /tmp diff --git a/scripts/dockerfiles/Dockerfile.test b/scripts/dockerfiles/Dockerfile.test index 11bc3de246e..242b508e7d5 100644 --- a/scripts/dockerfiles/Dockerfile.test +++ b/scripts/dockerfiles/Dockerfile.test @@ -17,6 +17,7 @@ # Because the Agent's tests include starting docker containers, it is necessary # to have both go and docker available in the testing environment. # It's easier to get go, so start with docker-in-docker and add go on top + FROM jpetazzo/dind MAINTAINER Amazon Web Services, Inc. @@ -32,7 +33,9 @@ RUN apt-get update && apt-get install -y \ --no-install-recommends \ && rm -rf /var/lib/apt/lists/* -ENV GOLANG_VERSION 1.15 +ARG GO_VERSION=1.15 + +ENV GOLANG_VERSION ${GO_VERSION} ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz ENV GOLANG_DOWNLOAD_SHA256 d7d1f1f88ddfe55840712dc1747f37a790cbcaa448f6c9cf51bbe10aa65442f5