github.com/apache/beam/sdks/v2@v2.48.2/go/container/build.gradle (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one
     3   * or more contributor license agreements.  See the NOTICE file
     4   * distributed with this work for additional information
     5   * regarding copyright ownership.  The ASF licenses this file
     6   * to you under the Apache License, Version 2.0 (the
     7   * License); you may not use this file except in compliance
     8   * with the License.  You may obtain a copy of the License at
     9   *
    10   *     http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   * Unless required by applicable law or agreed to in writing, software
    13   * distributed under the License is distributed on an AS IS BASIS,
    14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15   * See the License for the specific language governing permissions and
    16   * limitations under the License.
    17   */
    18  
    19  plugins { id 'org.apache.beam.module' }
    20  applyGoNature()
    21  applyDockerNature()
    22  
    23  description = "Apache Beam :: SDKs :: Go :: Container"
    24  
    25  goBuild {
    26    goTargets = '*.go' // only build the immediate directory.
    27    outputLocation = './build/target/${GOOS}_${GOARCH}/boot'
    28  }
    29  
    30  docker {
    31    name containerImageName(
    32            name: project.docker_image_default_repo_prefix + "go_sdk",
    33            root: project.rootProject.hasProperty(["docker-repository-root"]) ?
    34                    project.rootProject["docker-repository-root"] :
    35                    project.docker_image_default_repo_root)
    36    // tags used by dockerTag task
    37    tags containerImageTags()
    38    files "./build/"
    39    buildArgs(['pull_licenses': project.rootProject.hasProperty(["docker-pull-licenses"]) ||
    40                       project.rootProject.hasProperty(["isRelease"])])
    41    buildx project.containerPlatforms() != [project.nativeArchitecture()]
    42    platform(*project.containerPlatforms())
    43  }
    44  dockerPrepare.dependsOn tasks.named("goBuild")
    45  
    46  // Ensure that making the docker image builds any required artifacts
    47  if (project.rootProject.hasProperty(["docker-pull-licenses"])) {
    48    task copyGolangLicenses(type: Copy) {
    49      project.logger.lifecycle('docker-pull-licenses set, running go-licenses')
    50      from "${project(':release:go-licenses:go').buildDir}/output"
    51      into "build/target/go-licenses"
    52      dependsOn ':release:go-licenses:go:createLicenses'
    53    }
    54    dockerPrepare.dependsOn 'copyGolangLicenses'
    55  } else {
    56    task skipPullLicenses(type: Exec) {
    57      project.logger.lifecycle('docker-pull-licenses not set, skipping go-licenses')
    58      executable "sh"
    59      // Touch a dummy file to ensure the directory exists.
    60      args "-c", "mkdir -p build/target/go-licenses && touch build/target/go-licenses/skip"
    61    }
    62    dockerPrepare.dependsOn 'skipPullLicenses'
    63  }
    64  
    65  task pushAll {
    66    dependsOn ":sdks:go:container:dockerPush"
    67  }