FROM registry.access.redhat.com/ubi8/ubi:latest

ARG GO_PACKAGE_PATH=github.com/jenkinsci/jenkins-automation-operator

# Basics
ENV GIT_COMMITTER_NAME="OpenShift Developer Sevices"
ENV GIT_COMMITTER_EMAIL=openshift-dev-services+jenkins@redhat.com
ENV LANG=en_US.utf8

# Go
ENV GOPATH=/tmp/go
ENV GO_VERSION=1.14.1
ENV GO_DOWNLOAD_SITE=https://dl.google.com/go/
ENV GO_DIST=go$GO_VERSION.linux-amd64.tar.gz

# Operator SDK
ENV OPERATOR_SDK_VERSION=v0.17.0 
ENV OPERATOR_SDK_DOWNLOAD_SITE=https://github.com/operator-framework/operator-sdk/releases/download/ 
ENV OPERATOR_SDK_DIST=operator-sdk-OPERATOR_SDK_VERSION-x86_64-linux-gnu

# kubectl
ENV KUBECTL_VERSION=v1.14.3 
ENV KUBECTL_DOWNLOAD_SITE=https://storage.googleapis.com/kubernetes-release/release/
ENV PATH=:$GOPATH/bin:/tmp/goroot/go/bin:/usr/bin:/usr/local/bin:/usr/sbin:$PATH

WORKDIR /tmp
RUN mkdir -p $GOPATH/bin &&  mkdir -p /tmp/goroot
RUN echo $GO_DOWNLOAD_SITE/$GO_DIST
RUN curl -Lo $GO_DIST $GO_DOWNLOAD_SITE/$GO_DIST
RUN tar -C /tmp/goroot -xzf $GO_DIST
RUN curl -Lo kubectl $KUBECTL_DOWNLOAD_SITE/$KUBECTL_VERSION/bin/linux/amd64/kubectl
RUN chmod +x kubectl && mv kubectl $GOPATH/bin/
RUN curl -Lo operator-sdk $OPERATOR_SDK_DOWNLOAD_SITE/$OPERATOR_SDK_VERSION/$OPERATOR_SDK_DIST
RUN chmod +x operator-sdk && mv operator-sdk $GOPATH/bin/
RUN mkdir -p ${GOPATH}/src/${GO_PACKAGE_PATH}/
RUN yum -y install --nodocs git make gcc diffutils 
RUN go get -u golang.org/x/lint/golint && go install $_
RUN go get -u golang.org/x/tools/cmd/goimports && go install $_
RUN go get -u honnef.co/go/tools/cmd/staticcheck && go install $_
RUN go get -u github.com/mrtazz/checkmake/cmd/checkmake && go install $_

WORKDIR ${GOPATH}/src/${GO_PACKAGE_PATH}
ENTRYPOINT [ "/bin/bash" ]

