/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

def pythonVersionSuffix = project.ext.pythonVersion.replace('.', '')

description = "Apache Beam :: SDKs :: Python :: Container :: Distroless :: Python ${pythonVersionSuffix} Container"


def pushContainers = project.rootProject.hasProperty(["isRelease"]) || project.rootProject.hasProperty("push-containers")
def base_name = project.docker_image_default_repo_prefix + "python${project.ext.pythonVersion}_sdk"
def root = project.rootProject.hasProperty(["docker-repository-root"]) ?
                    project.rootProject["docker-repository-root"] :
                    project.docker_image_default_repo_root
def tag = project.rootProject.hasProperty(["docker-tag"]) ?
                    project.rootProject["docker-tag"] : project.sdk_version

def base = containerImageName(
            name: base_name,
            root: root,
            tag: tag)

docker {
    name containerImageName(
        name: "${base_name}_distroless",
        root: root,
        tag: tag)
    // tags used by dockerTag task
    tags containerImageTags()
    files "../Dockerfile", "./build"
    buildArgs(['BASE': "${base}"])
    buildx project.useBuildx()
    platform(*project.containerPlatforms())
    load project.useBuildx() && !pushContainers
    push pushContainers
}

dockerPrepare.dependsOn ":sdks:python:container:py${pythonVersionSuffix}:docker"

