# Copyright 2019 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------

FROM devtools/go-toolset-1.10-rhel7 AS builder
ENV GOPATH /tmp/go
RUN mkdir -p /tmp/go/src/github.com/interconnectedcloud/qdr-operator/_build
WORKDIR /tmp/go/src/github.com/interconnectedcloud/qdr-operator
ADD src /tmp/go/src/github.com/interconnectedcloud/qdr-operator
RUN /opt/rh/go-toolset-1.10/root/usr/bin/go build -o ./_build/qdr-operator ./cmd/manager/main.go

FROM ubi7:7-released
WORKDIR /root/licenses/amq-interconnect-operator-container/
ADD licenses.tgz /root/licenses/amq-interconnect-operator-container/
# image builder does not (yet?) support automatic extraction for ADD (https://github.com/openshift/imagebuilder/issues/99)
RUN tar -zxf /root/licenses/amq-interconnect-operator-container/licenses.tgz && rm /root/licenses/amq-interconnect-operator-container/licenses.tgz
COPY --from=builder /tmp/go/src/github.com/interconnectedcloud/qdr-operator/_build/qdr-operator /usr/bin/
ENV QDROUTERD_IMAGE amq7/amq-interconnect:1.8
ADD olm/1.2.0 /manifests
WORKDIR /usr/bin
ENTRYPOINT ["qdr-operator"]

LABEL \
      com.redhat.component="amq-interconnect-operator-container"  \
      description="Red Hat Integration AMQ Interconnect Operator"  \
      io.k8s.description="An operator for AMQ Interconnect."  \
      io.k8s.display-name="Red Hat Integration AMQ Interconnect Operator"  \
      io.openshift.tags="messaging,amq"  \
      maintainer="Gordon Sim <gsim@redhat.com>"  \
      name="amq7/amq-interconnect-operator"  \
      summary="Red Hat Integration AMQ Interconnect Operator"  \
      com.redhat.delivery.appregistry=true  \
      version="1.2"
