Skip to content

Commit 7613055

Browse files
committed
modify Makefile to use different Golang version while building Agent for Windows
1 parent e06c355 commit 7613055

6 files changed

+30
-10
lines changed

Makefile

+18-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ else
2222
GOARCH=amd64
2323
endif
2424

25+
ifeq (${TARGET_OS},windows)
26+
GO_VERSION=1.12
27+
else
28+
GO_VERSION=1.15
29+
endif
30+
2531
all: docker
2632

2733
# Dynamic go build; useful in that it does not have -a so it won't recompile
@@ -47,7 +53,7 @@ xplatform-build:
4753

4854
BUILDER_IMAGE="amazon/amazon-ecs-agent-build:make"
4955
.builder-image-stamp: scripts/dockerfiles/Dockerfile.build
50-
@docker build -f scripts/dockerfiles/Dockerfile.build -t $(BUILDER_IMAGE) .
56+
@docker build --build-arg GO_VERSION=$(GO_VERSION) -f scripts/dockerfiles/Dockerfile.build -t $(BUILDER_IMAGE) .
5157
touch .builder-image-stamp
5258

5359
# 'build-in-docker' builds the agent within a dockerfile and saves it to the ./out
@@ -71,11 +77,17 @@ docker: certs build-in-docker pause-container-release cni-plugins .out-stamp
7177
@docker build -f scripts/dockerfiles/Dockerfile.release -t "amazon/amazon-ecs-agent:make" .
7278
@echo "Built Docker image \"amazon/amazon-ecs-agent:make\""
7379

80+
ifeq (${TARGET_OS},windows)
81+
BUILD="cleanbuild-${TARGET_OS}"
82+
else
83+
BUILD=cleanbuild
84+
endif
85+
7486
# 'docker-release' builds the agent from a clean snapshot of the git repo in
7587
# 'RELEASE' mode
7688
# TODO: make this idempotent
7789
docker-release: pause-container-release cni-plugins .out-stamp
78-
@docker build -f scripts/dockerfiles/Dockerfile.cleanbuild -t "amazon/amazon-ecs-agent-cleanbuild:make" .
90+
@docker build --build-arg GO_VERSION=${GO_VERSION} -f scripts/dockerfiles/Dockerfile.cleanbuild -t "amazon/amazon-ecs-agent-${BUILD}:make" .
7991
@docker run --net=none \
8092
--env TARGET_OS="${TARGET_OS}" \
8193
--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
8496
--volume "$(PWD)/out:/out" \
8597
--volume "$(PWD):/src/amazon-ecs-agent" \
8698
--rm \
87-
"amazon/amazon-ecs-agent-cleanbuild:make"
99+
"amazon/amazon-ecs-agent-${BUILD}:make"
88100

89101
# Release packages our agent into a "scratch" based dockerfile
90102
release: certs docker-release
@@ -181,7 +193,7 @@ get-cni-sources:
181193
git submodule update --init --recursive
182194

183195
build-ecs-cni-plugins:
184-
@docker build -f scripts/dockerfiles/Dockerfile.buildECSCNIPlugins -t "amazon/amazon-ecs-build-ecs-cni-plugins:make" .
196+
@docker build --build-arg GO_VERSION=$(GO_VERSION) -f scripts/dockerfiles/Dockerfile.buildECSCNIPlugins -t "amazon/amazon-ecs-build-ecs-cni-plugins:make" .
185197
docker run --rm --net=none \
186198
-e GIT_SHORT_HASH=$(shell cd $(ECS_CNI_REPOSITORY_SRC_DIR) && git rev-parse --short=8 HEAD) \
187199
-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:
192204
@echo "Built amazon-ecs-cni-plugins successfully."
193205

194206
build-vpc-cni-plugins:
195-
@docker build --build-arg GOARCH=$(GOARCH) -f scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins -t "amazon/amazon-ecs-build-vpc-cni-plugins:make" .
207+
@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" .
196208
docker run --rm --net=none \
197209
-e GIT_SHORT_HASH=$(shell cd $(VPC_CNI_REPOSITORY_SRC_DIR) && git rev-parse --short=8 HEAD) \
198210
-u "$(USERID)" \
@@ -331,6 +343,7 @@ clean:
331343
# ensure docker is running and we can talk to it, abort if not:
332344
docker ps > /dev/null
333345
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild:make"
346+
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild-windows:make"
334347
rm -f misc/certs/ca-certificates.crt &> /dev/null
335348
rm -rf out/
336349
-$(MAKE) -C $(ECS_CNI_REPOSITORY_SRC_DIR) clean

scripts/dockerfiles/Dockerfile.build

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

14-
FROM golang:1.12
14+
ARG GO_VERSION
15+
FROM golang:${GO_VERSION}
1516
MAINTAINER Amazon Web Services, Inc.
1617

1718
ENV XDG_CACHE_HOME /tmp

scripts/dockerfiles/Dockerfile.buildECSCNIPlugins

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

14-
FROM golang:1.15
14+
ARG GO_VERSION
15+
FROM golang:${GO_VERSION}
1516
MAINTAINER Amazon Web Services, Inc.
1617

1718
ENV XDG_CACHE_HOME /tmp

scripts/dockerfiles/Dockerfile.buildVPCCNIPlugins

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

14-
FROM golang:1.15
14+
ARG GO_VERSION
15+
FROM golang:${GO_VERSION}
1516
MAINTAINER Amazon Web Services, Inc.
1617

1718
ARG GOARCH

scripts/dockerfiles/Dockerfile.cleanbuild

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313

14-
FROM golang:1.15
14+
ARG GO_VERSION
15+
FROM golang:${GO_VERSION}
1516
MAINTAINER Amazon Web Services, Inc.
1617

1718
ENV XDG_CACHE_HOME /tmp

scripts/dockerfiles/Dockerfile.test

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Because the Agent's tests include starting docker containers, it is necessary
1818
# to have both go and docker available in the testing environment.
1919
# It's easier to get go, so start with docker-in-docker and add go on top
20+
2021
FROM jpetazzo/dind
2122
MAINTAINER Amazon Web Services, Inc.
2223

@@ -32,7 +33,9 @@ RUN apt-get update && apt-get install -y \
3233
--no-install-recommends \
3334
&& rm -rf /var/lib/apt/lists/*
3435

35-
ENV GOLANG_VERSION 1.15
36+
ARG GO_VERSION=1.15
37+
38+
ENV GOLANG_VERSION ${GO_VERSION}
3639
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
3740
ENV GOLANG_DOWNLOAD_SHA256 d7d1f1f88ddfe55840712dc1747f37a790cbcaa448f6c9cf51bbe10aa65442f5
3841

0 commit comments

Comments
 (0)