]> go.fuhry.dev Git - runtime.git/commitdiff
add coredns nfpm package
authorDan Fuhry <dan@fuhry.com>
Wed, 8 Jul 2026 12:21:08 +0000 (08:21 -0400)
committerDan Fuhry <dan@fuhry.com>
Wed, 8 Jul 2026 12:21:08 +0000 (08:21 -0400)
mtls/BUILD.bazel
pkg/BUILD.bazel
pkg/coredns.yaml [new file with mode: 0644]
pkg/nfpmgen/config_generator.go
thirdparty/coredns/BUILD.bazel
thirdparty/coredns/plugin/BUILD.bazel

index e570fe916f4bb0a557f4030c4c2f1c3d5a5d4c6e..a6db2808c75af9c3a6fbcbb7a1ea445e93401872 100644 (file)
@@ -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",
     ],
 )
index 6618f23c9cc2518e64bfd1ff85be6b68f00fd637..87d805b16d1483ddb56f90288b66c0524a062e2e 100644 (file)
@@ -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 (file)
index 0000000..980c28e
--- /dev/null
@@ -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 <bazelbuild@${const:RootDomain}>"
+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
index 52b397e1470a6a9d2fafe440f29470c950d692da..0f4aeb3e48050edacb9d9a537c85317109e9918a 100644 (file)
@@ -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...)
+                       }
                }
        }
 
index 38b97d83f99d598c34a56b49c9d66eea9170fc2e..e3f7da5c029039241dfe337a9b7b577cd26b4cb2 100644 (file)
@@ -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",
+)
index ee610d5796abd40a302d3f4834c5ef8e082ec123..69d738cb34379fc19e110f0f7781eafc5c182587 100644 (file)
@@ -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(