mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
2nd attempt of #63111, a follow up https://github.com/sourcegraph/sourcegraph/pull/63085 rules_oci 2.0 brings a lot of performance improvement around oci_image and oci_pull, which will benefit Sourcegraph. It will also make RBE faster and have less load on remote cache. However, 2.0 makes some breaking changes like - oci_tarball's default output is no longer a tarball - oci_image no longer compresses layers that are uncompressed, somebody has to make sure all `pkg_tar` targets have a `compression` attribute set to compress it beforehand. - there is no curl fallback, but this is fine for sourcegraph as it already uses bazel 7.1. I checked all targets that use oci_tarball as much as i could to make sure nothing depends on the default tarball output of oci_tarball. there was one target which used the default output which i put a TODO for somebody else (somebody who is more on top of the repo) to tackle **later**. ## Test plan CI. Also run delivery on this PR (don't land those changes) --------- Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
128 lines
2.9 KiB
Python
128 lines
2.9 KiB
Python
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
|
load("//dev:oci_defs.bzl", "image_repository", "oci_image", "oci_push", "oci_tarball")
|
|
load("//dev:oci_defs.bzl", "pkg_tar")
|
|
load("@container_structure_test//:defs.bzl", "container_structure_test")
|
|
load("//wolfi-images:defs.bzl", "wolfi_base")
|
|
|
|
go_library(
|
|
name = "executor_lib",
|
|
srcs = ["main.go"],
|
|
importpath = "github.com/sourcegraph/sourcegraph/cmd/executor",
|
|
tags = [TAG_SEARCHSUITE],
|
|
visibility = ["//visibility:private"],
|
|
deps = [
|
|
"//cmd/executor/internal/config",
|
|
"//cmd/executor/internal/run",
|
|
"//cmd/executor/internal/util",
|
|
"//internal/env",
|
|
"//internal/hostname",
|
|
"//internal/logging",
|
|
"//internal/sanitycheck",
|
|
"//internal/version",
|
|
"@com_github_sourcegraph_log//:log",
|
|
"@com_github_urfave_cli_v2//:cli",
|
|
],
|
|
)
|
|
|
|
go_binary(
|
|
name = "executor",
|
|
embed = [":executor_lib"],
|
|
tags = [TAG_SEARCHSUITE],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
# Ensure this builds, so we don't fail at publish time later on in the pipeline.
|
|
build_test(
|
|
name = "executor_build_test",
|
|
targets = [":executor"],
|
|
)
|
|
|
|
go_binary(
|
|
name = "executor_sh",
|
|
basename = "executor",
|
|
embed = [":executor_lib"],
|
|
gotags = [
|
|
"shell",
|
|
],
|
|
tags = [TAG_SEARCHSUITE],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "tar_executor",
|
|
srcs = [":executor"],
|
|
visibility = ["//cmd/bundled-executor:__pkg__"],
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "tar_batcheshelper",
|
|
srcs = ["//cmd/batcheshelper"],
|
|
package_dir = "/usr/local/bin",
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "tar_src-cli",
|
|
srcs = ["@src-cli-linux-amd64//:src-cli-linux-amd64"],
|
|
package_dir = "/usr/local/bin",
|
|
)
|
|
|
|
oci_image(
|
|
name = "image",
|
|
base = ":base_image",
|
|
entrypoint = [
|
|
"/sbin/tini",
|
|
"--",
|
|
"/executor",
|
|
],
|
|
env = {
|
|
"EXECUTOR_USE_FIRECRACKER": "false", # Firecracker doesn't work in docker, so disable it by default
|
|
},
|
|
tars = [
|
|
":tar_executor",
|
|
":tar_src-cli",
|
|
":tar_batcheshelper",
|
|
],
|
|
user = "sourcegraph",
|
|
)
|
|
|
|
oci_tarball(
|
|
name = "image_tarball",
|
|
image = ":image",
|
|
repo_tags = ["executor:candidate"],
|
|
)
|
|
|
|
container_structure_test(
|
|
name = "image_test",
|
|
timeout = "short",
|
|
configs = ["image_test.yaml"],
|
|
driver = "docker",
|
|
image = ":image",
|
|
tags = [
|
|
TAG_SEARCHSUITE,
|
|
"exclusive",
|
|
"requires-network",
|
|
],
|
|
)
|
|
|
|
oci_push(
|
|
name = "candidate_push",
|
|
image = ":image",
|
|
repository = image_repository("executor"),
|
|
)
|
|
|
|
sh_binary(
|
|
name = "binary.push",
|
|
srcs = ["_binary.push.sh"],
|
|
args = [
|
|
"$(location //dev/tools:gsutil)",
|
|
"$(location :executor)",
|
|
],
|
|
data = [
|
|
":executor",
|
|
"//dev/tools:gsutil",
|
|
],
|
|
)
|
|
|
|
wolfi_base()
|