# Copyright 2019 The Kubernetes Authors.
#
# 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.

# Build the manager binary
FROM openshift/golang-builder:1.12 AS builder
ENV __doozer=update BUILD_RELEASE=202009151447.p0 BUILD_VERSION=v4.3.37 OS_GIT_MAJOR=4 OS_GIT_MINOR=3 OS_GIT_PATCH=37 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.3.37-202009151447.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=7c97911 OS_GIT_VERSION=4.3.37-202009151447.p0-7c97911 SOURCE_DATE_EPOCH=1594343104 SOURCE_GIT_COMMIT=7c9791175fdaeebce154e9b4be064c31f5ee5aa4 SOURCE_GIT_TAG=v0.1.0-alpha.3-108-g7c979117 SOURCE_GIT_URL=https://github.com/openshift/cluster-api-provider-azure 

# Copy in the go src
WORKDIR /go/src/sigs.k8s.io/cluster-api-provider-azure
COPY pkg/    pkg/
COPY cmd/    cmd/
COPY vendor/ vendor/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o ./machine-controller-manager sigs.k8s.io/cluster-api-provider-azure/cmd/manager
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o ./manager ./vendor/github.com/openshift/cluster-api/cmd/manager

# Copy the controller-manager into a thin image
FROM openshift/ose-base:v4.3.37.20200915.151322
ENV __doozer=update BUILD_RELEASE=202009151447.p0 BUILD_VERSION=v4.3.37 OS_GIT_MAJOR=4 OS_GIT_MINOR=3 OS_GIT_PATCH=37 OS_GIT_TREE_STATE=clean OS_GIT_VERSION=4.3.37-202009151447.p0 SOURCE_GIT_TREE_STATE=clean 
ENV __doozer=merge OS_GIT_COMMIT=7c97911 OS_GIT_VERSION=4.3.37-202009151447.p0-7c97911 SOURCE_DATE_EPOCH=1594343104 SOURCE_GIT_COMMIT=7c9791175fdaeebce154e9b4be064c31f5ee5aa4 SOURCE_GIT_TAG=v0.1.0-alpha.3-108-g7c979117 SOURCE_GIT_URL=https://github.com/openshift/cluster-api-provider-azure 
WORKDIR /
COPY --from=builder /go/src/sigs.k8s.io/cluster-api-provider-azure/manager .
COPY --from=builder /go/src/sigs.k8s.io/cluster-api-provider-azure/machine-controller-manager .

LABEL \
        name="openshift/ose-azure-machine-controllers" \
        com.redhat.component="ose-azure-machine-controllers-container" \
        io.openshift.maintainer.product="OpenShift Container Platform" \
        release="202009151447.p0" \
        io.openshift.build.commit.id="7c9791175fdaeebce154e9b4be064c31f5ee5aa4" \
        io.openshift.build.source-location="https://github.com/openshift/cluster-api-provider-azure" \
        io.openshift.build.commit.url="https://github.com/openshift/cluster-api-provider-azure/commit/7c9791175fdaeebce154e9b4be064c31f5ee5aa4" \
        version="v4.3.37"

