FROM openshift/golang-builder:rhel_8_golang_1.16 AS builder
ENV __doozer=update BUILD_RELEASE=202111020858.p0.git.d3f5899.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202111020858.p0.git.d3f5899.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=d3f5899143e3f59e8ad7eb6c0d7af3c8dcb95559 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=18+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.18.10+d3f5899 OS_GIT_COMMIT=d3f5899 OS_GIT_VERSION=4.9.0-202111020858.p0.git.d3f5899.assembly.stream-d3f5899 SOURCE_DATE_EPOCH=1631185333 SOURCE_GIT_COMMIT=d3f5899143e3f59e8ad7eb6c0d7af3c8dcb95559 SOURCE_GIT_TAG=helm-chart-aws-efs-csi-driver-1.0.0-160-gd3f5899 SOURCE_GIT_URL=https://github.com/openshift/aws-efs-csi-driver 
WORKDIR /go/src/github.com/kubernetes-sigs/aws-efs-csi-driver
COPY . .
RUN make

# Use a base image with aws-efs-utils installed
FROM openshift/ose-aws-efs-utils-base:v4.9.0.20211102.090836
ENV __doozer=update BUILD_RELEASE=202111020858.p0.git.d3f5899.assembly.stream BUILD_VERSION=v4.9.0 OS_GIT_MAJOR=4 OS_GIT_MINOR=9 OS_GIT_PATCH=0 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.9.0-202111020858.p0.git.d3f5899.assembly.stream SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge KUBE_GIT_COMMIT=d3f5899143e3f59e8ad7eb6c0d7af3c8dcb95559 KUBE_GIT_MAJOR=1 KUBE_GIT_MINOR=18+ KUBE_GIT_TREE_STATE=clean KUBE_GIT_VERSION=v1.18.10+d3f5899 OS_GIT_COMMIT=d3f5899 OS_GIT_VERSION=4.9.0-202111020858.p0.git.d3f5899.assembly.stream-d3f5899 SOURCE_DATE_EPOCH=1631185333 SOURCE_GIT_COMMIT=d3f5899143e3f59e8ad7eb6c0d7af3c8dcb95559 SOURCE_GIT_TAG=helm-chart-aws-efs-csi-driver-1.0.0-160-gd3f5899 SOURCE_GIT_URL=https://github.com/openshift/aws-efs-csi-driver 

# From the upstream Dockerfile:
# At image build time, static files installed by efs-utils in the config directory, i.e. CAs file, need
# to be saved in another place so that the other stateful files created at runtime, i.e. private key for
# client certificate, in the same config directory can be persisted to host with a host path volume.
# Otherwise creating a host path volume for that directory will clean up everything inside at the first time.
# Those static files need to be copied back to the config directory when the driver starts up.
RUN mv /etc/amazon/efs /etc/amazon/efs-static-files

COPY --from=builder /go/src/github.com/kubernetes-sigs/aws-efs-csi-driver/bin/aws-efs-csi-driver /usr/bin/
ENTRYPOINT ["/usr/bin/aws-efs-csi-driver"]

LABEL \
        name="openshift/ose-aws-efs-csi-driver-container-rhel8" \
        com.redhat.component="ose-aws-efs-csi-driver-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        io.openshift.maintainer.component="Storage" \
        release="202111020858.p0.git.d3f5899.assembly.stream" \
        io.openshift.build.commit.id="d3f5899143e3f59e8ad7eb6c0d7af3c8dcb95559" \
        io.openshift.build.source-location="https://github.com/openshift/aws-efs-csi-driver" \
        io.openshift.build.commit.url="https://github.com/openshift/aws-efs-csi-driver/commit/d3f5899143e3f59e8ad7eb6c0d7af3c8dcb95559" \
        version="v4.9.0"

