#
# This is the image that controls the standard build environment for releasing OpenShift Origin.
# It is responsible for performing a cross platform build of OpenShift.
#
# The standard name for this image is openshift/origin-release
#
FROM openshift/origin-base

ENV VERSION=1.4.3 \
    GOARM=5 \
    GOPATH=/go \
    GOROOT=/usr/local/go \
    OS_VERSION_FILE=/go/src/github.com/openshift/origin/os-version-defs \
    TMPDIR=/openshifttmp
ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin

ADD *.rpm /tmp/origin-rpm/
RUN mkdir $TMPDIR && \
    INSTALL_PKGS="make gcc zip mercurial krb5-devel bsdtar bc rsync bind-utils file jq tito createrepo openssl" && \
    yum install -y $INSTALL_PKGS /tmp/origin-rpm/*.rpm && \
    rpm -V $INSTALL_PKGS && \
    yum clean all && \
    curl -L https://github.com/google/protobuf/releases/download/v3.0.0-beta-4/protoc-3.0.0-beta-4-linux-x86_64.zip | bsdtar -C /usr/local -xf - && \
    chmod uga+x /usr/local/bin/protoc && \
    curl https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz | tar -C /usr/local -xzf - && \
    touch /os-build-image && \
    git config --global user.name origin-release-container && \
    git config --global user.email none@nowhere.com

WORKDIR /go/src/github.com/openshift/origin
LABEL io.k8s.display-name="OpenShift Origin Release Environment (golang-$VERSION)" \
      io.k8s.description="This is the standard release image for OpenShift Origin and contains the necessary build tools to build the platform."

# Expect a tar with the source of OpenShift Origin (and /os-version-defs in the root)
# This image is for OpenShift versions v1.2.0 and earlier.
CMD bsdtar mxzf - && hack/build-cross.sh
