FROM registry.redhat.io/rhel8/go-toolset:latest AS builder
ENV SOURCE_GIT_COMMIT=a5a771479f73be6be4207aadc730351e515aedfb \
    SOURCE_DATE_EPOCH=1581603464 \
    BUILD_VERSION=v1.3.1 \
    SOURCE_GIT_URL=https://github.com/openshift/source-to-image \
    SOURCE_GIT_TAG=v1.3.1-11-geed2850f

ENV S2I_GIT_VERSION=v1.3.1 \
    S2I_GIT_MAJOR=1 \
    S2I_GIT_MINOR=3

USER root

WORKDIR /tmp/source-to-image
COPY source-to-image-a5a771479f73be6be4207aadc730351e515aedfb.tar.gz .

RUN tar -xvzf source-to-image-a5a771479f73be6be4207aadc730351e515aedfb.tar.gz --strip-components=1 && rm source-to-image-a5a771479f73be6be4207aadc730351e515aedfb.tar.gz

# ENV GOARCH="amd64"

RUN make

RUN cp _output/local/bin/$(go env GOHOSTOS)/$(go env GOHOSTARCH)/s2i _output/s2i
#
# Runner Image
#

FROM registry.redhat.io/ubi8/ubi-minimal:latest
ENV SOURCE_GIT_COMMIT=a5a771479f73be6be4207aadc730351e515aedfb \
    SOURCE_DATE_EPOCH=1581603464 \
    BUILD_VERSION=v1.3.1 \
    SOURCE_GIT_URL=https://github.com/openshift/source-to-image \
    SOURCE_GIT_TAG=v1.3.1-11-geed2850f

COPY --from=builder /tmp/source-to-image/_output/s2i  /usr/local/bin/s2i

USER 1001

ENTRYPOINT [ "/usr/local/bin/s2i" ]

LABEL \
        io.k8s.description="source to image" \
        com.redhat.component="source-to-image-container" \
        name="ocp-tools-4-tech-preview/source-to-image-rhel8" \
        io.k8s.display-name="source to image" \
        io.openshift.build.source-location=https://github.com/openshift/source-to-image \
        io.openshift.build.commit.url=https://github.com/openshift/source-to-image/commit/a5a771479f73be6be4207aadc730351e515aedfb \
        version=v1.3.1 \
        io.openshift.build.commit.id=a5a771479f73be6be4207aadc730351e515aedfb
