/*
 * Copyright (c) 2019 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
 */

plugins {
    id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}"
    id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
    id 'java'
}

group = 'org.eclipse.jkube.integration.tests.gradle'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

import org.eclipse.jkube.kit.config.image.build.BuildConfiguration
kubernetes {
    offline = true
    images {
        image {
            name = 'repository/groovy-dsl-image-test:latest'
            build {
                from = 'alpine'
                env {
                    JAVA_OPTIONS = '-Xmx256m'
                }
                labels {
                    MAINTAINER = 'JKube testing team'
                }
                assembly {
                    targetDir = '/deployments'
                    layers = [{
                        fileSets = [{
                            directory = file('src/static')
                            outputDirectory = file('static')
                        }]
                    }]
                }
                ports = ['8080']
                entryPoint {
                    shell = "java -jar /deployments/${project.name}-${project.version}.jar"
                }
            }
        }
    }
    addImage {builder ->
        builder.name = 'repository/groovy-dsl-image-with-builder:latest'
        builder.build(BuildConfiguration.builder()
            .from('alpine')
            .env([
                JAVA_OPTIONS: '-Xmx256m'
            ])
            .label('MAINTAINER','JKube testing team (builder)')
            .port('8082')
            .build())
    }
}
