| Tim Windelschmidt | 32e7430 | 2025-01-15 04:37:26 +0100 | [diff] [blame] | 1 | load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template") |
| 2 | load("@bazel_skylib//rules:write_file.bzl", "write_file") |
| 3 | load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push") |
| 4 | load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink") |
| 5 | load("@rules_pkg//pkg:tar.bzl", "pkg_tar") |
| 6 | |
| 7 | # Because bazeldnf writes multiple files when using their symlink feature, |
| 8 | # we have to do them manually with a second layer. |
| 9 | # https://github.com/rmohr/bazeldnf/issues/88 |
| 10 | pkg_mklink( |
| 11 | name = "ld-link", |
| 12 | link_name = "usr/bin/ld", |
| 13 | target = "/usr/bin/ld.bfd", |
| 14 | ) |
| 15 | |
| 16 | pkg_tar( |
| 17 | name = "links", |
| 18 | srcs = [ |
| 19 | ":ld-link", |
| 20 | ], |
| 21 | ) |
| 22 | |
| 23 | oci_image( |
| 24 | name = "remote_worker_image", |
| 25 | base = "@distroless_base", |
| 26 | entrypoint = [], |
| 27 | tags = ["no-remote"], |
| 28 | tars = [ |
| 29 | "//third_party/sandboxroot:sandbox", |
| 30 | ":links", |
| 31 | ], |
| 32 | visibility = ["//visibility:private"], |
| 33 | workdir = "/root", |
| 34 | ) |
| 35 | |
| 36 | write_file( |
| 37 | name = "tags_tmpl", |
| 38 | out = "tags.txt.tmpl", |
| 39 | content = [ |
| 40 | "BUILD_VERSION", |
| 41 | ], |
| 42 | ) |
| 43 | |
| 44 | # Use the value of --embed_label under --stamp, otherwise use a deterministic constant |
| 45 | # value to ensure cache hits for actions that depend on this. |
| 46 | expand_template( |
| 47 | name = "stamped", |
| 48 | out = "_stamped.tags.txt", |
| 49 | stamp_substitutions = {"BUILD_VERSION": "{{STABLE_MONOGON_metropolis_version}}"}, |
| 50 | substitutions = {"BUILD_VERSION": "0.0.0"}, |
| 51 | template = "tags_tmpl", |
| 52 | ) |
| 53 | |
| 54 | oci_push( |
| 55 | name = "remote_worker_push", |
| 56 | image = ":remote_worker_image", |
| 57 | remote_tags = ":stamped", |
| 58 | repository = "gcr.io/monogon-infra/sandbox", |
| 59 | ) |