From 08139881e595224cf4d567ef395aaf5571feabfc Mon Sep 17 00:00:00 2001
From: Cyrill Troxler <cyrilltroxler@gmail.com>
Date: Mon, 5 Apr 2021 12:46:05 +0200
Subject: [PATCH] Update docker images

* Use go 1.16
* Use debian buster for dependencies
---
 cmd/s3driver/Dockerfile      | 12 ++++++++++--
 cmd/s3driver/Dockerfile.full | 14 +++++++++++---
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/cmd/s3driver/Dockerfile b/cmd/s3driver/Dockerfile
index 8e36c1a..87fea7f 100644
--- a/cmd/s3driver/Dockerfile
+++ b/cmd/s3driver/Dockerfile
@@ -1,4 +1,12 @@
-FROM debian:stretch
+FROM golang:1.16-alpine as gobuild
+
+WORKDIR /build
+ADD . /build
+
+RUN go get -d -v ./...
+RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver
+
+FROM debian:buster-slim
 LABEL maintainers="Cyrill Troxler <cyrilltroxler@gmail.com>"
 LABEL description="csi-s3 slim image"
 
@@ -16,5 +24,5 @@ RUN cd /tmp \
   && mv /tmp/rclone-*-linux-amd64/rclone /usr/bin \
   && rm -r /tmp/rclone*
 
-COPY ./_output/s3driver /s3driver
+COPY --from=gobuild /build/s3driver /s3driver
 ENTRYPOINT ["/s3driver"]
diff --git a/cmd/s3driver/Dockerfile.full b/cmd/s3driver/Dockerfile.full
index 58bfcd3..e973625 100644
--- a/cmd/s3driver/Dockerfile.full
+++ b/cmd/s3driver/Dockerfile.full
@@ -1,4 +1,12 @@
-FROM debian:stretch as s3backer
+FROM golang:1.16-alpine as gobuild
+
+WORKDIR /build
+ADD . /build
+
+RUN go get -d -v ./...
+RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver
+
+FROM debian:buster-slim as s3backer
 ARG S3BACKER_VERSION=1.5.0
 
 RUN apt-get update && apt-get install -y \
@@ -24,7 +32,7 @@ RUN ./autogen.sh && \
   make && \
   make install
 
-FROM debian:stretch
+FROM debian:buster-slim
 LABEL maintainers="Cyrill Troxler <cyrilltroxler@gmail.com>"
 LABEL description="csi-s3 image"
 COPY --from=s3backer /usr/bin/s3backer /usr/bin/s3backer
@@ -44,5 +52,5 @@ RUN cd /tmp \
   && mv /tmp/rclone-*-linux-amd64/rclone /usr/bin \
   && rm -r /tmp/rclone*
 
-COPY ./_output/s3driver /s3driver
+COPY --from=gobuild /build/s3driver /s3driver
 ENTRYPOINT ["/s3driver"]