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 " 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 " 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"]