github.com/apache/beam/sdks/v2@v2.48.2/python/expansion-service-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 {
    20    id 'base'
    21    id 'org.apache.beam.module'
    22  }
    23  applyDockerNature()
    24  applyPythonNature()
    25  applyGoNature()
    26  
    27  configurations {
    28    dockerDependency
    29  }
    30  
    31  dependencies {
    32   dockerDependency project(path: ":sdks:python", configuration: "distTarBall")
    33  }
    34  
    35  task copyDockerfileDependencies(type: Copy) {
    36      from configurations.dockerDependency
    37      rename 'apache-beam.*tar.gz', 'apache-beam-sdk.tar.gz'
    38      setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
    39      into "build/target"
    40  }
    41  
    42  task copyRequirementsFile(type: Copy) {
    43      from project(':sdks:python:container:py38').fileTree("./")
    44      include 'base_image_requirements.txt'
    45      rename 'base_image_requirements.txt', 'requirements.txt'
    46      setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
    47      into "build/target"
    48  }
    49  
    50  goBuild {
    51    goTargets = '*.go' // only build the immediate directory.
    52    outputLocation = './build/target/launcher/${GOOS}_${GOARCH}/boot'
    53  }
    54  
    55  def copyLicenseScripts = tasks.register("copyLicenseScripts", Copy){
    56      from project(':sdks:python:container').fileTree("./license_scripts")
    57      into "build/target/license_scripts"
    58  }
    59  
    60  docker {
    61    name containerImageName(
    62            name: project.docker_image_default_repo_prefix + "python_expansion_service",
    63            root: project.rootProject.hasProperty(["docker-repository-root"]) ?
    64                    project.rootProject["docker-repository-root"] :
    65                    project.docker_image_default_repo_root,
    66            tag: project.rootProject.hasProperty(["docker-tag"]) ?
    67                    project.rootProject["docker-tag"] : project.sdk_version)
    68    // tags used by dockerTag task
    69    tags containerImageTags()
    70    files "./build"
    71    buildx project.containerPlatforms() != [project.nativeArchitecture()]
    72    platform(*project.containerPlatforms())
    73  }
    74  
    75  dockerPrepare.dependsOn goBuild
    76  dockerPrepare.dependsOn copyDockerfileDependencies
    77  dockerPrepare.dependsOn copyRequirementsFile
    78  dockerPrepare.dependsOn copyLicenseScripts
    79  
    80  if (project.rootProject.hasProperty(["docker-pull-licenses"])) {
    81      def copyGolangLicenses = tasks.register("copyGolangLicenses", Copy) {
    82          from "${project(':release:go-licenses:py').buildDir}/output"
    83          into "build/target/go-licenses"
    84          dependsOn ':release:go-licenses:py:createLicenses'
    85      }
    86      dockerPrepare.dependsOn copyGolangLicenses
    87  } else {
    88      def skipPullLicenses = tasks.register("skipPullLicenses", Exec) {
    89          executable "sh"
    90          // Touch a dummy file to ensure the directory exists.
    91          args "-c", "mkdir -p build/target/go-licenses && touch build/target/go-licenses/skip"
    92      }
    93      dockerPrepare.dependsOn skipPullLicenses
    94  }
    95  
    96  task pushAll {
    97    dependsOn dockerPush
    98  }