From: Dan Fuhry Date: Wed, 8 Jul 2026 12:21:08 +0000 (-0400) Subject: add coredns nfpm package X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=b4c6caf5cbbe6f35e967600f323f058df97fca93;p=runtime.git add coredns nfpm package --- diff --git a/mtls/BUILD.bazel b/mtls/BUILD.bazel index e570fe9..a6db280 100644 --- a/mtls/BUILD.bazel +++ b/mtls/BUILD.bazel @@ -68,8 +68,8 @@ go_multi_library( "//utils/hostname", "//utils/log", "//utils/subst", - "@com_github_thalesignite_crypto11//:crypto11", "@com_github_keybase_go_keychain//:go-keychain", + "@com_github_thalesignite_crypto11//:crypto11", "@in_gopkg_yaml_v3//:yaml_v3", ], ) diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 6618f23..87d805b 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -57,3 +57,11 @@ nfpm_package( "//cmd/prometheus_http_discovery:prometheus_http_discovery_systemd_service", ], ) + +nfpm_package( + name = "coredns", + config = ":coredns.yaml", + data = [ + "//thirdparty/coredns", + ], +) diff --git a/pkg/coredns.yaml b/pkg/coredns.yaml new file mode 100644 index 0000000..980c28e --- /dev/null +++ b/pkg/coredns.yaml @@ -0,0 +1,15 @@ +name: "${const:ExePrefix}coredns" +arch: "amd64" +platform: "linux" +version: "${sub:${const:Version},+unset,}" +section: "net" +priority: "extra" +maintainer: "Bazel Build Service " +depends: + - ${const:ExePrefix}runtime-utils +description: | + Custom CoreDNS build. +vendor: "${const:OrgName}" +homepage: "https://go.fuhry.dev/runtime" +license: "Proprietary" +contents: [] \ No newline at end of file diff --git a/pkg/nfpmgen/config_generator.go b/pkg/nfpmgen/config_generator.go index 52b397e..0f4aeb3 100644 --- a/pkg/nfpmgen/config_generator.go +++ b/pkg/nfpmgen/config_generator.go @@ -136,8 +136,10 @@ func (c *NfpmConfig) DiscoverBinaries(bazelBinDirs []string) error { dedup := hashset.NewHashSet[string]() for _, dir := range bazelBinDirs { - if dirEntries, err := os.ReadDir(path.Join(wd, dir, "cmd")); err == nil { - entries = append(entries, dirEntries...) + for _, subdir := range []string{"cmd", "thirdparty"} { + if dirEntries, err := os.ReadDir(path.Join(wd, dir, subdir)); err == nil { + entries = append(entries, dirEntries...) + } } } diff --git a/thirdparty/coredns/BUILD.bazel b/thirdparty/coredns/BUILD.bazel index 38b97d8..e3f7da5 100644 --- a/thirdparty/coredns/BUILD.bazel +++ b/thirdparty/coredns/BUILD.bazel @@ -1,6 +1,7 @@ -load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:cross.bzl", "go_cross_binaries") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:subst.bzl", "subst") +load("//bazel:svc.bzl", "systemd_service") subst( name = "plugin_cfg", @@ -33,4 +34,21 @@ go_cross_binaries( base_target = "coredns", linux_arm = True, openbsd = True, -) \ No newline at end of file +) + +systemd_service( + name = "coredns@", + args = [ + "-conf=/etc/coredns/Corefile.%i", + "-pidfile=/run/coredns.%i.pid", + "-mtls.config=${const:SystemConfDir}/mtls-files-only.yaml", + "-etcd.srv-domain=${const:DefaultHostDomain}", + "-etcd.startup-timeout=1000", + "-mtls.id=etcd-client", + ], + description = "in-house build of coredns with special plugins - instance %i", + exe = "coredns", + group = "root", + type = "simple", + user = "root", +) diff --git a/thirdparty/coredns/plugin/BUILD.bazel b/thirdparty/coredns/plugin/BUILD.bazel index ee610d5..69d738c 100644 --- a/thirdparty/coredns/plugin/BUILD.bazel +++ b/thirdparty/coredns/plugin/BUILD.bazel @@ -5,24 +5,26 @@ go_multi_library( srcs = ["generate.go"], importpath = "go.fuhry.dev/runtime/thirdparty/coredns/plugin", ) + go_multi_binary( name = "generate", embed = [":generate_lib"], gotags = ["generate"], visibility = ["//thirdparty/coredns:__subpackages__"], ) + genrule( name = "zplugin_go", - outs = ["zplugin.go"], srcs = [ "//thirdparty/coredns:plugin_cfg", ], + outs = ["zplugin.go"], + cmd = """ + ./$(location :generate) -plugin-cfg "$<" > "$@" + """, tools = [ ":generate", ], - cmd = """ - ./$(location :generate) -plugin-cfg "$<" > "$@" - """ ) go_multi_library(