Skip to content

Commit

Permalink
modify Makefile to use different Golang version while building Agent …
Browse files Browse the repository at this point in the history
…for Windows
  • Loading branch information
mythri-garaga committed Oct 26, 2020
1 parent 9280bcf commit 8f27c69
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
22 changes: 17 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}"
VERSION=${GO_VERSION_WINDOWS}
else
BUILD=cleanbuild
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=${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) \
Expand All @@ -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
Expand Down Expand Up @@ -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/^ *//') \
Expand All @@ -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)" \
Expand Down
3 changes: 2 additions & 1 deletion scripts/dockerfiles/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
FROM golang:${GO_VERSION}
MAINTAINER Amazon Web Services, Inc.

ENV XDG_CACHE_HOME /tmp
Expand Down
3 changes: 2 additions & 1 deletion scripts/dockerfiles/Dockerfile.buildECSCNIPlugins
Original file line number Diff line number Diff line change
Expand Up @@ -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
FROM golang:${GO_VERSION}
MAINTAINER Amazon Web Services, Inc.

ENV XDG_CACHE_HOME /tmp
Expand Down
3 changes: 2 additions & 1 deletion scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins
Original file line number Diff line number Diff line change
Expand Up @@ -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
FROM golang:${GO_VERSION}
MAINTAINER Amazon Web Services, Inc.

ARG GOARCH
Expand Down
3 changes: 2 additions & 1 deletion scripts/dockerfiles/Dockerfile.cleanbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
FROM golang:${GO_VERSION}
MAINTAINER Amazon Web Services, Inc.

ENV XDG_CACHE_HOME /tmp
Expand Down
5 changes: 4 additions & 1 deletion scripts/dockerfiles/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down

0 comments on commit 8f27c69

Please sign in to comment.