github.com/apache/beam/sdks/v2@v2.48.2/typescript/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 applyDockerNature() 21 applyGoNature() 22 23 description = "Apache Beam :: SDKs :: Typescript :: Container" 24 25 configurations { 26 packTarball 27 } 28 29 dependencies { 30 packTarball project(path: ":sdks:typescript", configuration: "packTarball") 31 } 32 33 goBuild { 34 goTargets = '*.go' // only build the immediate directory. 35 outputLocation = './build/target/launcher/${GOOS}_${GOARCH}/boot' 36 } 37 38 def copyDockerfileDependencies = tasks.register("copyDockerfileDependencies", Copy) { 39 from configurations.packTarball 40 into "build/target" 41 if(configurations.packTarball.isEmpty()) { 42 throw new StopExecutionException("Empty sdk tarball."); 43 } 44 } 45 46 docker { 47 name containerImageName( 48 name: project.docker_image_default_repo_prefix + "typescript_sdk", 49 root: project.rootProject.hasProperty(["docker-repository-root"]) ? 50 project.rootProject["docker-repository-root"] : 51 project.docker_image_default_repo_root, 52 tag: project.rootProject.hasProperty(["docker-tag"]) ? 53 project.rootProject["docker-tag"] : project.sdk_version) 54 // tags used by dockerTag task 55 tags containerImageTags() 56 files "./build" 57 buildx project.containerPlatforms() != [project.nativeArchitecture()] 58 platform(*project.containerPlatforms()) 59 } 60 61 dockerPrepare.dependsOn goBuild 62 dockerPrepare.dependsOn copyDockerfileDependencies 63 64 if (project.rootProject.hasProperty(["docker-pull-licenses"])) { 65 def copyGolangLicenses = tasks.register("copyGolangLicenses", Copy) { 66 from "${project(':release:go-licenses:py').buildDir}/output" 67 into "build/target/go-licenses" 68 dependsOn ':release:go-licenses:py:createLicenses' 69 } 70 dockerPrepare.dependsOn copyGolangLicenses 71 } else { 72 def skipPullLicenses = tasks.register("skipPullLicenses", Exec) { 73 executable "sh" 74 // Touch a dummy file to ensure the directory exists. 75 args "-c", "mkdir -p build/target/go-licenses && touch build/target/go-licenses/skip" 76 } 77 dockerPrepare.dependsOn skipPullLicenses 78 } 79 80 task pushAll { 81 dependsOn ":sdks:typescript:container:dockerPush" 82 }