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()