You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2023/04/12 06:12:16 UTC

[apisix-ingress-controller] branch master updated: chore: use docker buildkit to cache go build cache (#1778)

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

zhangjintao 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 2f9a4c85 chore: use docker buildkit to cache go build cache (#1778)
2f9a4c85 is described below

commit 2f9a4c85a6f32d43b95e30059fba352a15771dbc
Author: Sarasa Kisaragi <li...@gmail.com>
AuthorDate: Wed Apr 12 14:12:10 2023 +0800

    chore: use docker buildkit to cache go build cache (#1778)
    
    Signed-off-by: Ling Samuel <li...@gmail.com>
---
 Dockerfile | 7 ++++---
 Makefile   | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 9c416887..e4f408dc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,5 @@
-#
+#syntax=docker/dockerfile:1.2
+
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
@@ -30,7 +31,7 @@ RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.cn,
     && go mod download
 
 COPY . .
-RUN make build
+RUN --mount=type=cache,target=/root/.cache/go-build make build
 
 FROM centos:centos7
 LABEL maintainer="gxthrj@163.com"
@@ -40,7 +41,7 @@ RUN yum -y install ca-certificates libc6-compat \
     && update-ca-trust \
     && echo "hosts: files dns" > /etc/nsswitch.conf
 
-COPY --from=build-env /build/apisix-ingress-controller .
 COPY --from=build-env /usr/share/zoneinfo/Hongkong /etc/localtime
+COPY --from=build-env /build/apisix-ingress-controller .
 
 ENTRYPOINT ["/ingress-apisix/apisix-ingress-controller", "ingress", "--config-path", "/ingress-apisix/conf/config.yaml"]
diff --git a/Makefile b/Makefile
index 93aa64f7..4585bb46 100644
--- a/Makefile
+++ b/Makefile
@@ -75,7 +75,7 @@ clean-image: ## Removes local image
 .PHONY: build-image
 build-image:
 ifeq ($(E2E_SKIP_BUILD), 0)
-	docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) .
+	DOCKER_BUILDKIT=1 docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) --build-arg ENABLE_PROXY=$(ENABLE_PROXY) .
 	docker tag apache/apisix-ingress-controller:$(IMAGE_TAG) $(REGISTRY)/apisix-ingress-controller:$(IMAGE_TAG)
 endif