# Copyright (c) 2019-2020 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#   Red Hat, Inc. - initial API and implementation
#

# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/devtools/go-toolset-rhel7
FROM devtools/go-toolset-rhel7:1.12.12-4 as builder
ENV PATH=/opt/rh/go-toolset-1.12/root/usr/bin:$PATH \
    GOPATH=/go/
USER root
WORKDIR /go/src/github.com/eclipse/che-plugin-broker/brokers/metadata/cmd/
COPY . /go/src/github.com/eclipse/che-plugin-broker/
RUN adduser appuser && \
    CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-w -s' -installsuffix cgo -o metadata-broker main.go

# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
FROM ubi8-minimal:8.1-409

RUN microdnf update -y systemd && microdnf clean all && rm -rf /var/cache/yum

USER appuser
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /go/src/github.com/eclipse/che-plugin-broker/brokers/metadata/cmd/metadata-broker /
ENTRYPOINT ["/metadata-broker"]

# append Brew metadata here
ENV SUMMARY="Red Hat CodeReady Workspaces pluginbroker-metadata container" \
        DESCRIPTION="Red Hat CodeReady Workspaces pluginbroker-metadata container" \
        PRODNAME="codeready-workspaces" \
        COMPNAME="pluginbroker-metadata-rhel8" 
    LABEL summary="$SUMMARY" \
          description="$DESCRIPTION" \
          io.k8s.description="$DESCRIPTION" \
          io.k8s.display-name="$DESCRIPTION" \
          io.openshift.tags="$PRODNAME,$COMPNAME" \
          com.redhat.component="$PRODNAME-$COMPNAME-container" \
          name="$PRODNAME/$COMPNAME" \
          version="2.1" \
          license="EPLv2" \
          maintainer="Nick Boldt <nboldt@redhat.com>" \
          io.openshift.expose-services="" \
          usage="" 
