Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use different Golang version while building Agent for Windows #2688

Merged
merged 1 commit into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ else
GOARCH=amd64
endif

ifeq (${TARGET_OS},windows)
GO_VERSION=1.12
else
GO_VERSION=1.15
endif

all: docker

# Dynamic go build; useful in that it does not have -a so it won't recompile
Expand All @@ -47,7 +53,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 +77,17 @@ 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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this variable still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be useful when we are playing with the scripts locally.

else
BUILD=cleanbuild
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) \
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 Expand Up @@ -331,6 +343,7 @@ clean:
# ensure docker is running and we can talk to it, abort if not:
docker ps > /dev/null
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild:make"
-docker rmi $(BUILDER_IMAGE) "amazon/amazon-ecs-agent-cleanbuild-windows:make"
rm -f misc/certs/ca-certificates.crt &> /dev/null
rm -rf out/
-$(MAKE) -C $(ECS_CNI_REPOSITORY_SRC_DIR) clean
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