From 04bba675d2956437a099f01ecaf4ddfc674d987c Mon Sep 17 00:00:00 2001
From: Chris Crone <christopher.crone@docker.com>
Date: Thu, 15 Apr 2021 14:39:13 +0200
Subject: [PATCH] aci-demo: Rework Dockerfiles

Signed-off-by: Chris Crone <christopher.crone@docker.com>
---
 aci/e2e/aci-demo/web/Dockerfile              | 20 ++++----------------
 aci/e2e/aci_secrets_resources/web/Dockerfile |  2 +-
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/aci/e2e/aci-demo/web/Dockerfile b/aci/e2e/aci-demo/web/Dockerfile
index ce8f6679b..259809bf8 100644
--- a/aci/e2e/aci-demo/web/Dockerfile
+++ b/aci/e2e/aci-demo/web/Dockerfile
@@ -12,24 +12,12 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 # BUILD
-FROM ubuntu:latest
-
-# Update and upgrade repo
-RUN apt-get update -y -q && apt-get upgrade -y -q
-
-# Install tools we might need
-RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -q curl build-essential ca-certificates git
-
-# Download Go 1.2.2 and install it to /usr/local/go
-RUN curl -s https://storage.googleapis.com/golang/go1.2.2.linux-amd64.tar.gz| tar -v -C /usr/local -xz
-
-# Let's people find our Go binaries
-ENV PATH $PATH:/usr/local/go/bin
-
+FROM golang:1.16-alpine AS build
 COPY dispatcher.go .
-RUN go build dispatcher.go
+RUN mkdir -p /out && go build -o /out/dispatcher dispatcher.go
 
+FROM alpine AS run
 EXPOSE 80
 CMD ["/dispatcher"]
-
 COPY static /static/
+COPY --from=build /out/dispatcher /dispatcher
diff --git a/aci/e2e/aci_secrets_resources/web/Dockerfile b/aci/e2e/aci_secrets_resources/web/Dockerfile
index 0c0bf2d73..2bb6398e6 100644
--- a/aci/e2e/aci_secrets_resources/web/Dockerfile
+++ b/aci/e2e/aci_secrets_resources/web/Dockerfile
@@ -18,7 +18,7 @@
 FROM golang:1.16-alpine AS build
 COPY main.go .
 RUN --mount=type=cache,target=/go/pkg/mod \
-    CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o server main.go
+    go build -trimpath -ldflags="-s -w" -o server main.go
 
 FROM alpine
 RUN apk --no-cache add curl