blob: 742d6845fdc72e17ddec6f9646aba1550861a1e7 [file] [log] [blame]
Tim Windelschmidt32e74302025-01-15 04:37:26 +01001load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
2load("@bazel_skylib//rules:write_file.bzl", "write_file")
3load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")
4load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink")
5load("@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
10pkg_mklink(
11 name = "ld-link",
12 link_name = "usr/bin/ld",
13 target = "/usr/bin/ld.bfd",
14)
15
16pkg_tar(
17 name = "links",
18 srcs = [
19 ":ld-link",
20 ],
21)
22
23oci_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
36write_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.
46expand_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
54oci_push(
55 name = "remote_worker_push",
56 image = ":remote_worker_image",
57 remote_tags = ":stamped",
58 repository = "gcr.io/monogon-infra/sandbox",
59)