Skip to content

Commit

Permalink
feat(examples): upgrade rules_docker to 0.14.1
Browse files Browse the repository at this point in the history
Also drop the patches we needed for older versions
  • Loading branch information
Fabian Wiles authored and gregmagolan committed Apr 22, 2020
1 parent 7b3858f commit cfb6d6e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 54 deletions.
4 changes: 4 additions & 0 deletions .circleci/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ build --local_cpu_resources=8
# Our integration tests rely on accessing public registries which can fail
# Let's give all failing tests a second try to mostly paper over flakiness
test --flaky_test_attempts=2

# Expose the SSH_AUTH_SOCK variable to integration tests that need to run git_repository repository rules
# This is needed by the CircleCI git-over-ssh environment
test --test_env=SSH_AUTH_SOCK
12 changes: 9 additions & 3 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ example_integration_test(
"@rayman1104",
"@siberex",
],
# Breaks on Windows with `rules_docker requires a python interpreter installed. Please set
# BAZEL_PYTHON, or put it on your path.`
tags = ["fix-windows"],
# Fails on transitive dep of rules_docker
# error running 'git init C:/users/b/_bazel_b/3oe2yqkh/external/rules_cc' while working with @rules_cc:
# java.io.IOException: ERROR: src/main/native/windows/process.cc(199): CreateProcessW("git" init C:/users/b/_bazel_b/3oe2yqkh/external/rules_cc): The system cannot find the file specified
#
# NB: even after working around that by fetching rules_cc with an http_archive we get a follow-on failure
# ERROR: Analysis of target '//src:docker' failed; build aborted: no such package '@nodejs_image_base//image': Pull command failed: java.io.IOException: ERROR: src/main/native/windows/process.cc(199): CreateProcessW("C:\users\b\_bazel_b\vanuqgg3\external\go_puller_linux\file\downloaded" -directory C:/users/b/_bazel_b/vanuqgg3/external/nodejs_image_base/image -os linux -os-version "" -os-features "" -architecture amd64 -variant "" -features "" -name gcr.io/google-appengine/debian9@sha256:c05b781371f75d1bd7a199bc83de177173cc80c98dbfb6c1ef7075757addece4): %1 is not a valid Win32 application.
# (error: 193) (C:/users/b/_bazel_b/vanuqgg3/external/go_puller_linux/file/downloaded -directory
# C:/users/b/_bazel_b/vanuqgg3/external/nodejs_image_base/image -os linux -os-version -os-features -architecture amd64 -variant -features -name gcr.io/google-appengine/debian9@sha256:c05b781371f75d1bd7a199bc83de177173cc80c98dbfb6c1ef7075757addece4)
tags = ["no-bazelci-windows"],
)

example_integration_test(
Expand Down
20 changes: 11 additions & 9 deletions examples/angular/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ workspace(
)

# These rules are built-into Bazel but we need to load them first to download more rules
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Fetch rules_nodejs so we can install our npm dependencies
Expand Down Expand Up @@ -99,10 +98,9 @@ http_archive(

http_archive(
name = "io_bazel_rules_docker",
patches = ["//:rules_docker.patch"],
sha256 = "7d453450e1eb70e238eea6b31f4115607ec1200e91afea01c25f9804f37e39c8",
strip_prefix = "rules_docker-0.10.0",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.10.0.tar.gz"],
sha256 = "dc97fccceacd4c6be14e800b2a00693d5e8d07f69ee187babfd04a80a9f8e250",
strip_prefix = "rules_docker-0.14.1",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.14.1/rules_docker-v0.14.1.tar.gz"],
)

load("@io_bazel_rules_docker//repositories:repositories.bzl", container_repositories = "repositories")
Expand All @@ -117,17 +115,21 @@ nodejs_image_repos()
# Kubernetes setup, for deployment to Google Cloud #
####################################################

git_repository(
http_archive(
name = "io_bazel_rules_k8s",
commit = "36ae5b534cc51ab0815c9bc723760469a9f7175c",
remote = "https://github.com/bazelbuild/rules_k8s.git",
shallow_since = "1545317854 -0500",
sha256 = "cc75cf0d86312e1327d226e980efd3599704e01099b58b3c2fc4efe5e321fcd9",
strip_prefix = "rules_k8s-0.3.1",
urls = ["https://github.com/bazelbuild/rules_k8s/releases/download/v0.3.1/rules_k8s-v0.3.1.tar.gz"],
)

load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_defaults", "k8s_repositories")

k8s_repositories()

load("@io_bazel_rules_k8s//k8s:k8s_go_deps.bzl", k8s_go_deps = "deps")

k8s_go_deps()

k8s_defaults(
# This creates a rule called "k8s_deploy" that we can call later
name = "k8s_deploy",
Expand Down
13 changes: 0 additions & 13 deletions examples/angular/rules_docker.patch

This file was deleted.

6 changes: 1 addition & 5 deletions examples/angular/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,10 @@ history_server(

nodejs_image(
name = "nodejs_image",
data = [":prodapp"],
entry_point = "@npm//:node_modules/history-server/modules/cli.js",
node_modules = "@npm//:node_modules",
binary = ":prodserver",
# Actions created by this rule are I/O-bound,
# so there is no benefit to running them remotely
tags = ["local"],
templated_args = ["src/prodapp"],
)

container_image(
Expand All @@ -238,7 +235,6 @@ container_image(
# Actions created by this rule are I/O-bound,
# so there is no benefit to running them remotely
tags = ["local"],
workdir = "/app/src/nodejs_image.binary.runfiles/examples_angular",
)

ts_library(
Expand Down
7 changes: 3 additions & 4 deletions examples/nestjs/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ install_bazel_dependencies()

http_archive(
name = "io_bazel_rules_docker",
patches = ["//:rules_docker.patch"],
sha256 = "7d453450e1eb70e238eea6b31f4115607ec1200e91afea01c25f9804f37e39c8",
strip_prefix = "rules_docker-0.10.0",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.10.0.tar.gz"],
sha256 = "dc97fccceacd4c6be14e800b2a00693d5e8d07f69ee187babfd04a80a9f8e250",
strip_prefix = "rules_docker-0.14.1",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.14.1/rules_docker-v0.14.1.tar.gz"],
)

load(
Expand Down
13 changes: 0 additions & 13 deletions examples/nestjs/rules_docker.patch

This file was deleted.

8 changes: 1 addition & 7 deletions examples/nestjs/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,5 @@ jasmine_node_test(
# bazel build --platforms=@build_bazel_rules_nodejs//toolchains/node:linux_amd64 //src:docker
nodejs_image(
name = "docker",
data = [
":app",
],
entry_point = ":main.ts",
# TODO: switch to fine grained deps -- see bazelbuild/rules_docker#1000
# and add test for docker image
node_modules = "@npm//:node_modules",
binary = ":server",
)
1 change: 1 addition & 0 deletions internal/bazel_integration_test/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ for (const bazelCommand of config.bazelCommands) {
delete env[key];
}
env['PWD'] = workspaceRoot;
env['HOME'] = require('os').homedir();
log_verbose(JSON.stringify(env, null, 2));
log(`running 'bazel ${bazelArgs.join(' ')}' in ${workspaceRoot}`);
spawnedProcess = spawnSync(bazelBinary, bazelArgs, {env, cwd: workspaceRoot, stdio: 'inherit'});
Expand Down

0 comments on commit cfb6d6e

Please sign in to comment.