• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ==============================================================================
17# Script for helping to record method for building the RBE docker images.
18#
19# The first argument to the script is expected to be the name of the docker file
20# to build. Example:
21#
22# $ ./build_rbe.sh Dockerfile.rbe.ubuntu16.04-manylinux2010
23
24function main() {
25  set -eu
26
27  cd "${0%/*}"
28
29  local DOCKERFILE="$(basename "$1")"
30  if [[ ! -e "$DOCKERFILE" ]]; then
31    echo "$DOCKERFILE does not exist in $PWD" >> /dev/stderr
32    exit 1
33  fi
34
35  local IMAGE_NAME_SUFFIX="${1#Dockerfile.rbe.}"
36  if [[ "$IMAGE_NAME_SUFFIX" == "$DOCKERFILE" ]]; then
37    echo 'File must start with "Dockerfile.rbe."' >> /dev/stderr
38    exit 1
39  fi
40
41  local ARGS=(
42    --config=cloudbuild.yaml
43    --machine-type=n1-highcpu-32
44    --substitutions=_DOCKERFILE="$1",_IMAGE_NAME="nosla-$IMAGE_NAME_SUFFIX"
45    --timeout=1h
46  )
47
48  gcloud --project=tensorflow-testing builds submit "${ARGS[@]}" .
49}
50
51main "$@"
52