You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by kv...@apache.org on 2021/04/06 09:42:21 UTC

[apisix-ingress-controller] branch master updated: chore: optimize dockerfile (#340)

This is an automated email from the ASF dual-hosted git repository.

kvn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 71cede8  chore: optimize dockerfile (#340)
71cede8 is described below

commit 71cede89622b1f6f38b530f98a6695cd275ed9d2
Author: Alex Zhang <to...@apache.org>
AuthorDate: Tue Apr 6 17:42:11 2021 +0800

    chore: optimize dockerfile (#340)
    
    * chore: optimize dockerfile
    
    * update
---
 Dockerfile | 10 +++++++++-
 Makefile   |  4 ++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 2aaee3e..c2d8558 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,13 +17,21 @@
 FROM golang:1.13.8 AS build-env
 LABEL maintainer="gxthrj@163.com"
 
+ARG ENABLE_PROXY=false
+
 RUN rm -rf /etc/localtime \
     && ln -s /usr/share/zoneinfo/Hongkong /etc/localtime \
     && dpkg-reconfigure -f noninteractive tzdata
 
 WORKDIR /build
+COPY go.mod .
+COPY go.sum .
+
+RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.cn,direct ; fi \
+    && go mod download
+
 COPY . .
-RUN GOPROXY=https://goproxy.cn,direct make build
+RUN make build
 
 FROM centos:centos7
 LABEL maintainer="gxthrj@163.com"
diff --git a/Makefile b/Makefile
index 0313bbd..baf1078 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ build:
 ### build-image:          Build apisix-ingress-controller image
 .PHONY: build-image
 build-image:
-	docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) .
+	docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=true .
 
 ### lint:                 Do static lint check
 .PHONY: lint
@@ -96,7 +96,7 @@ ifeq ($(E2E_SKIP_BUILD), 0)
 	docker tag kennethreitz/httpbin $(LOCAL_REGISTRY)/kennethreitz/httpbin
 	docker push $(LOCAL_REGISTRY)/kennethreitz/httpbin
 
-	docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) .
+	docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=true .
 	docker tag apache/apisix-ingress-controller:$(IMAGE_TAG) $(LOCAL_REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)
 	docker push $(LOCAL_REGISTRY)/apache/apisix-ingress-controller:$(IMAGE_TAG)
 endif