From 3a6fbec02a2fb1035f334e91087bb0400409986e Mon Sep 17 00:00:00 2001
From: Igor Leao <igor.leao@tfgco.com>
Date: Thu, 9 Aug 2018 14:39:58 -0300
Subject: [PATCH] Add portmap binary

---
 Makefile                               | 12 +++++++++++-
 scripts/dockerfiles/Dockerfile.release |  2 ++
 scripts/install-aws.sh                 |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 3af3c2145a..31368d32ea 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,15 @@
 VERSION ?= $(shell git describe --tags --always --dirty)
 LDFLAGS ?= -X main.version=$(VERSION)
 
+# Download portmap plugin
+download-portmap:
+	mkdir -p tmp/downloads
+	mkdir -p tmp/plugins
+	curl -L -o tmp/downloads/cni-plugins-amd64.tgz https://github.com/containernetworking/plugins/releases/download/v0.6.0/cni-plugins-amd64-v0.6.0.tgz
+	tar -vxf tmp/downloads/cni-plugins-amd64.tgz -C tmp/plugins
+	cp tmp/plugins/portmap .
+	rm -rf tmp
+
 # Default to build the Linux binary
 build-linux:
 	GOOS=linux CGO_ENABLED=0 go build -o aws-k8s-agent -ldflags "$(LDFLAGS)"
@@ -26,7 +35,7 @@ docker-build:
 	docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s \
 		--workdir=/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s \
 		--env GOPATH=/usr/src/app \
-		golang:1.10 make build-linux
+		golang:1.10 make build-linux && make download-portmap
 
 
 # Build docker image
@@ -64,3 +73,4 @@ vet:
 clean:
 	rm -f aws-k8s-agent
 	rm -f aws-cni
+	rm -f portmap
diff --git a/scripts/dockerfiles/Dockerfile.release b/scripts/dockerfiles/Dockerfile.release
index 1d4c6d3b23..bdbdd7c28c 100644
--- a/scripts/dockerfiles/Dockerfile.release
+++ b/scripts/dockerfiles/Dockerfile.release
@@ -8,6 +8,8 @@ WORKDIR /app
 COPY aws-cni /app 
 COPY misc/10-aws.conflist /app
 
+COPY portmap /app
+
 COPY aws-k8s-agent  /app
 COPY scripts/aws-cni-support.sh /app
 COPY scripts/install-aws.sh /app
diff --git a/scripts/install-aws.sh b/scripts/install-aws.sh
index 7505fced4f..3c3c3cf196 100755
--- a/scripts/install-aws.sh
+++ b/scripts/install-aws.sh
@@ -2,6 +2,7 @@
 echo "=====Starting installing AWS-CNI ========="
 sed -i s/__VETHPREFIX__/${AWS_VPC_K8S_CNI_VETHPREFIX:-"eni"}/g /app/10-aws.conflist
 cp /app/aws-cni /host/opt/cni/bin/
+cp /app/portmap /host/opt/cni/bin/
 cp /app/aws-cni-support.sh /host/opt/cni/bin/
 cp /app/10-aws.conflist /host/etc/cni/net.d/
 echo "=====Starting amazon-k8s-agent ==========="