Use pre-built bazel-docker-gcloud container. (#172)
* Use pre-built bazel-docker-gcloud container.
diff --git a/container/README.md b/container/README.md
index f20fb76..5501489 100644
--- a/container/README.md
+++ b/container/README.md
@@ -25,6 +25,11 @@
### Build with [Google Cloud Container Builder](https://cloud.google.com/container-builder/)
+**Note: currently, this process can only be executed by users who have
+read access to asci-toolchains's GCR. We publish it here to make the build
+process for our containers publicly available. You can still build the
+containers locally. See instructions in the next section.**
+
You will need a valid project ID to build the toolchain-container.
You can build a toolchain-container with
diff --git a/container/build.py b/container/build.py
index fa08caa..490cf92 100644
--- a/container/build.py
+++ b/container/build.py
@@ -270,13 +270,6 @@
bazel_toolchains_base_dir)
extra_substitution = ""
- # If script is called within this repo, then we don't need @bazel_toolchains
- # target names (causes infinite symlink chain). If script is called from outside,
- # we do need it.
- bazel_toolchains_ref = "@bazel_toolchains"
- if os.path.samefile(bazel_toolchains_base_dir, "."):
- bazel_toolchains_ref = ""
-
async_arg = ""
if async_:
async_arg = "--async"
@@ -286,7 +279,6 @@
"--config={CONFIG} "
"--substitutions _PROJECT={PROJECT},_CONTAINER={CONTAINER},"
"_BAZEL_VERSION={BAZEL_VERSION},"
- "_BAZEL_TOOLCHAINS_REF={BAZEL_TOOLCHAINS_REF},"
"_TAG={TAG},_PACKAGE={PACKAGE},_TARGET={TARGET}{EXTRA_SUBSTITUTION} "
"--machine-type=n1-highcpu-32 "
"{ASYNC}").format(
@@ -294,7 +286,6 @@
PROJECT=project,
CONTAINER=container,
TAG=tag,
- BAZEL_TOOLCHAINS_REF=bazel_toolchains_ref,
PACKAGE=package,
TARGET=target,
EXTRA_SUBSTITUTION=extra_substitution,
diff --git a/container/cloudbuild.yaml b/container/cloudbuild.yaml
index de5520b..7715690 100644
--- a/container/cloudbuild.yaml
+++ b/container/cloudbuild.yaml
@@ -19,27 +19,17 @@
timeout: 21600s
steps:
-# Step: build a custom container with bazel
- - name: 'gcr.io/cloud-builders/bazel'
- args:
- - '--output_base=/workspace'
- - 'run'
- - '${_BAZEL_TOOLCHAINS_REF}//container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
- id: 'builder'
- waitFor:
- - "-" # wait for nothing - start immediately
-
# Step: print the bazel version for confirmation
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args:
- 'bazel'
- 'version'
id: 'version'
waitFor:
- - "builder"
+ - "-" # wait for nothing - start immediately
# Step: build the fully loaded container using rules_docker
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
# Set Bazel output_base to /workspace, which is a mounted directory on Google Cloud Builder.
# This is to make sure Bazel generated files can be accessed by multiple containers.
args: [
@@ -56,7 +46,7 @@
- 'version'
# Step: re-tag the image
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args: ['docker', 'tag', 'bazel/${_PACKAGE}:${_TARGET}', 'gcr.io/${_PROJECT}/${_CONTAINER}:${_TAG}']
id: 'container-tag'
waitFor: # wait for all artifacts to be ready
@@ -65,7 +55,7 @@
# Step: test the image
# We use container_test rule, which is a Bazel wrapper of container_structure_test.
# https://github.com/bazelbuild/rules_docker/blob/master/contrib/test.bzl
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args: [
'bazel',
'--output_base=/workspace',
@@ -81,7 +71,7 @@
- 'container-build'
# Step: store the tarball of debian packages in GCS
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args: ['gsutil',
'cp',
'/workspace/bazel-out/k8-fastbuild/bin/${_PACKAGE}/${_TARBALL}',
@@ -89,7 +79,7 @@
]
id: 'upload-debs'
waitFor:
- - 'container-build'
+ - 'image-test'
# Build the release-container
images:
diff --git a/container/cloudbuild_no_bucket.yaml b/container/cloudbuild_no_bucket.yaml
index c08d9bb..696378b 100644
--- a/container/cloudbuild_no_bucket.yaml
+++ b/container/cloudbuild_no_bucket.yaml
@@ -19,27 +19,17 @@
timeout: 21600s
steps:
-# Step: build a custom container with bazel
- - name: 'gcr.io/cloud-builders/bazel'
- args:
- - '--output_base=/workspace'
- - 'run'
- - '${_BAZEL_TOOLCHAINS_REF}//container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
- id: 'builder'
- waitFor:
- - "-" # wait for nothing - start immediately
-
# Step: print the bazel version for confirmation
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args:
- 'bazel'
- 'version'
id: 'version'
waitFor:
- - "builder"
+ - "-" # wait for nothing - start immediately
# Step: build the fully loaded container using rules_docker
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
# Set Bazel output_base to /workspace, which is a mounted directory on Google Cloud Builder.
# This is to make sure Bazel generated files can be accessed by multiple containers.
args: [
@@ -56,7 +46,7 @@
- 'version'
# Step: re-tag the image
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args: ['docker', 'tag', 'bazel/${_PACKAGE}:${_TARGET}', 'gcr.io/${_PROJECT}/${_CONTAINER}:${_TAG}']
id: 'container-tag'
waitFor: # wait for all artifacts to be ready
@@ -65,7 +55,7 @@
# Step: test the image
# We use container_test rule, which is a Bazel wrapper of container_structure_test.
# https://github.com/bazelbuild/rules_docker/blob/master/contrib/test.bzl
- - name: 'bazel/container/ubuntu16_04/builders/bazel_docker_gcloud:bazel_${_BAZEL_VERSION}_docker_gcloud'
+ - name: 'gcr.io/asci-toolchain/nosla-ubuntu16_04-bazel-docker-gcloud:${_BAZEL_VERSION}'
args: [
'bazel',
'--output_base=/workspace',