Skip to content

Commit 1d8908e

Browse files
authored
Merge pull request #1974 from GoogleContainerTools/test_new_rules_oci
refactor: support latest rules_oci
2 parents 986fa62 + f553653 commit 1d8908e

File tree

30 files changed

+616
-717
lines changed

30 files changed

+616
-717
lines changed

.bazelrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
# Take care to document any settings that you expect users to apply.
33
# Settings that apply only to CI are in .github/workflows/ci.bazelrc
44

5-
# Allow DOCKER_HOST env to leak into test actions.
5+
# Allow DOCKER_HOST env to leak into test actions.
66
test --test_env=DOCKER_HOST
77

8-
# Stamp
8+
# Stamp
99
build:release --workspace_status_command=./private/stamp.bash --stamp
1010
run:release --workspace_status_command=./private/stamp.bash --stamp
1111
test:release --workspace_status_command=./private/stamp.bash --stamp
1212

1313
# Allow external dependencies to be retried. debian snapshot is unreliable and needs retries.
1414
common --experimental_repository_downloader_retries=20
15+
common --experimental_downloader_config=downloader.cfg
1516
common --http_timeout_scaling=2.0
1617

1718
# Enable platform specific options

.github/workflows/ci.yaml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,10 @@ jobs:
3333
restore-keys: |
3434
bazel-cache-deps-ci1-${{ github.sha }}
3535
bazel-cache-deps-ci1-
36-
- name: Free space
37-
run: |
38-
sudo apt-get remove -y '^dotnet-.*'
39-
sudo apt-get remove -y '^llvm-.*'
40-
sudo apt-get remove -y 'php.*'
41-
sudo apt-get remove -y azure-cli google-cloud-cli google-chrome-stable firefox powershell mono-devel
42-
sudo apt-get autoremove -y
43-
sudo apt-get clean
44-
rm -rf /usr/share/dotnet/
36+
4537
- name: Fetch # this can take a long time if there are a lot of errors
4638
run: |
47-
for i in $(seq 10); do
39+
for i in $(seq 10); do
4840
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc fetch //... && break || sleep 180;
4941
done
5042
- name: Build All Images
@@ -71,19 +63,10 @@ jobs:
7163
restore-keys: |
7264
bazel-cache-deps-ci2-${{ github.sha }}
7365
bazel-cache-deps-ci2-
74-
- name: Free space
75-
run: |
76-
sudo apt-get remove -y '^dotnet-.*'
77-
sudo apt-get remove -y '^llvm-.*'
78-
sudo apt-get remove -y 'php.*'
79-
sudo apt-get remove -y azure-cli google-cloud-cli google-chrome-stable firefox powershell mono-devel
80-
sudo apt-get autoremove -y
81-
sudo apt-get clean
82-
rm -rf /usr/share/dotnet/
8366
8467
- name: Fetch
8568
run: |
86-
for i in $(seq 20); do
69+
for i in $(seq 20); do
8770
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc cquery 'attr(tags, "amd64", ...)' && break
8871
sleep 10;
8972
done

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Follow either of the two links above to access the appropriate CLA and instructi
2020
3. For building and loading images to your local Docker engine, you need to add a new rule for that image to the BUILD:
2121

2222
```starlark
23-
load("@rules_oci//oci:defs.bzl", "oci_tarball")
23+
load("@rules_oci//oci:defs.bzl", "oci_load")
2424

25-
oci_tarball(
25+
oci_load(
2626
name = "local_build",
2727
image = "//base:static_root_amd64_debian17",
2828
repo_tags = [],

MODULE.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ module(name = "distroless")
44

55
bazel_dep(name = "bazel_skylib", version = "1.8.1")
66
bazel_dep(name = "aspect_bazel_lib", version = "2.21.1")
7+
bazel_dep(name = "rules_pkg", version = "1.1.0")
78
bazel_dep(name = "platforms", version = "1.0.0")
89
bazel_dep(name = "rules_go", version = "0.57.0")
910
bazel_dep(name = "gazelle", version = "0.38.0")
10-
bazel_dep(name = "rules_pkg", version = "1.1.0")
1111
bazel_dep(name = "rules_rust", version = "0.63.0")
1212
bazel_dep(name = "container_structure_test", version = "1.19.1")
13-
bazel_dep(name = "rules_oci", version = "1.8.0")
14-
bazel_dep(name = "rules_distroless", version = "0.5.3")
13+
bazel_dep(name = "rules_oci", version = "2.2.7")
14+
bazel_dep(name = "rules_distroless", version = "0.6.2")
1515
bazel_dep(name = "rules_python", version = "1.5.3")
1616
bazel_dep(name = "rules_cc", version = "0.2.0")
1717

1818
### OCI ###
19+
# Note: rules_oci registers toolchains in its MODULE.bazel
20+
# We import the repos to use crane in sign_and_push rule
1921
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
20-
oci.toolchains(crane_version = "v0.18.0")
2122
use_repo(oci, "oci_crane_toolchains")
2223

2324
### PYTHON ###

MODULE.bazel.lock

Lines changed: 137 additions & 309 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

base/base.bzl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"defines a function to replicate the container images for different distributions"
22

33
load("@container_structure_test//:defs.bzl", "container_structure_test")
4-
load("@rules_go//go:def.bzl", "go_binary")
54
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_image_index")
6-
load("@rules_pkg//:pkg.bzl", "pkg_tar")
7-
load("//common:variables.bzl", "DEBUG_MODE", "NONROOT", "USERS")
5+
load("//common:variables.bzl", "DEBUG_MODE", "USERS")
86
load("//private/util:deb.bzl", "deb")
97

108
def base_nossl_image_index(distro, architectures):

common/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tar(
1818
"gnutar",
1919
],
2020
compress = "gzip",
21-
mtree = ["./ type=dir uid=0 gid=0 time=0.0"],
21+
mtree = ["./ type=dir uid=0 gid=0 mode=0755 time=0.0"],
2222
)
2323

2424
tar(

downloader.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rewrite (mirrors\.kernel\.org)/gnu/(.*) https://ftp.gnu.org/gnu/$2
2+
rewrite (mirrors\.kernel\.org)/gnu/(.*) https://ftpmirror.gnu.org/gnu/$2

examples/go/BUILD

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Public notice: this file is for internal documentation, testing, and
22
# reference only. Note that repo maintainers can freely change any part of the
33
# repository code at any time.
4-
load("@rules_oci//oci:defs.bzl", "oci_tarball")
4+
load("@rules_oci//oci:defs.bzl", "oci_load")
55
load("//private/oci:defs.bzl", "go_image")
66

77
package(default_visibility = ["//visibility:public"])
@@ -13,10 +13,9 @@ go_image(
1313
)
1414

1515
# Run
16-
# bazel build //examples/go:tarball
17-
# podman load -i bazel-bin/examples/go/tarball/tarball.tar
16+
# bazel run //examples/go:tarball
1817
# podman run localhost/distroless/examples/go:latest
19-
oci_tarball(
18+
oci_load(
2019
name = "tarball",
2120
image = ":go_example",
2221
repo_tags = ["distroless/examples/go:latest"],

examples/nodejs/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# repository code at any time.
44
load("@container_structure_test//:defs.bzl", "container_structure_test")
55
load("@rules_oci//oci:defs.bzl", "oci_image")
6-
load("@rules_pkg//:pkg.bzl", "pkg_tar")
6+
load("//private/util:tar.bzl", "tar")
77

88
package(default_visibility = ["//visibility:public"])
99

@@ -20,14 +20,14 @@ DISTROS = [
2020
# These examples are adapted from:
2121
# https://howtonode.org/hello-node
2222

23-
pkg_tar(
23+
tar(
2424
name = "hello_tar",
2525
srcs = [
2626
"hello.js",
2727
],
2828
)
2929

30-
pkg_tar(
30+
tar(
3131
name = "hello_http_tar",
3232
srcs = [
3333
"hello_http.js",

0 commit comments

Comments
 (0)