Skip to content

Commit ff6886e

Browse files
committed
feat: makefile to build binary and image at local machine
Signed-off-by: STRRL <[email protected]>
1 parent 9f9e425 commit ff6886e

File tree

5 files changed

+1217
-0
lines changed

5 files changed

+1217
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
# binary artifact
18+
coredns

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# syntax=docker/dockerfile:experimental
2+
3+
FROM golang:1.19 AS build-env
4+
ENV GO111MODULE on
5+
WORKDIR /
6+
RUN git clone --depth 1 --branch v1.7.0 https://github.com/coredns/coredns
7+
COPY . /k8s_dns_chaos
8+
RUN ln -s /k8s_dns_chaos /coredns/plugin/k8s_dns_chaos
9+
RUN echo "k8s_dns_chaos:k8s_dns_chaos" >> plugin.cfg
10+
RUN cd coredns && make
11+
12+
FROM debian:stable-slim AS certs
13+
RUN apt-get update && apt-get -uy upgrade
14+
RUN apt-get -y install ca-certificates && update-ca-certificates
15+
16+
FROM scratch
17+
LABEL org.opencontainers.image.source=https://github.com/chaos-mesh/k8s_dns_chaos
18+
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
19+
COPY --from=build-env /coredns/coredns /coredns
20+
EXPOSE 53 53/udp
21+
ENTRYPOINT ["/coredns"]

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.DEFAULT_GOAL:=help
2+
3+
.PHONY: image
4+
image: ## Build the latest container image
5+
DOCKER_BUILDKIT=1 docker build -t ghcr.io/chaos-mesh/chaos-coredns:latest .
6+
7+
.PHONY: coredns
8+
coredns: image ## Build the coredns executable binary
9+
docker container create --name extract-coredns ghcr.io/chaos-mesh/chaos-coredns:latest
10+
docker container cp extract-coredns:/coredns ./coredns
11+
docker container rm -f extract-coredns
12+
13+
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
14+
# The awk commands is responsible to read the entire set of makefiles included in this invocation, looking for lines of the file as xyz: ## something, and then pretty-format the target and help. Then, if there's a line with ##@ something, that gets pretty-printed as a category.
15+
# More info over the usage of ANSI control characters for terminal formatting: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
16+
# More info over awk command: http://linuxcommand.org/lc3_adv_awk.php
17+
.PHONY: help
18+
help: ## Display this help
19+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

go.mod

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module github.com/chaos-mesh/k8s_dns_chaos
2+
3+
go 1.19
4+
5+
require (
6+
github.com/caddyserver/caddy v1.0.5
7+
github.com/coredns/coredns v1.7.0
8+
github.com/golang/protobuf v1.5.2
9+
github.com/miekg/dns v1.1.43
10+
github.com/pingcap/tidb-tools v6.3.0+incompatible
11+
github.com/prometheus/client_golang v1.11.0
12+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
13+
google.golang.org/grpc v1.41.0
14+
k8s.io/api v0.22.2
15+
k8s.io/apimachinery v0.22.2
16+
k8s.io/client-go v0.22.2
17+
k8s.io/klog v1.0.0
18+
)
19+
20+
require (
21+
cloud.google.com/go v0.94.1 // indirect
22+
github.com/beorn7/perks v1.0.1 // indirect
23+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
24+
github.com/davecgh/go-spew v1.1.1 // indirect
25+
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
26+
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
27+
github.com/go-logr/logr v1.0.0 // indirect
28+
github.com/gogo/protobuf v1.3.2 // indirect
29+
github.com/google/go-cmp v0.5.6 // indirect
30+
github.com/google/gofuzz v1.2.0 // indirect
31+
github.com/google/uuid v1.1.2 // indirect
32+
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
33+
github.com/googleapis/gnostic v0.5.5 // indirect
34+
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
35+
github.com/imdario/mergo v0.3.12 // indirect
36+
github.com/json-iterator/go v1.1.11 // indirect
37+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
38+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
39+
github.com/modern-go/reflect2 v1.0.1 // indirect
40+
github.com/opentracing/opentracing-go v1.2.0 // indirect
41+
github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0 // indirect
42+
github.com/pingcap/errors v0.11.4 // indirect
43+
github.com/pkg/errors v0.9.1 // indirect
44+
github.com/prometheus/client_model v0.2.0 // indirect
45+
github.com/prometheus/common v0.31.1 // indirect
46+
github.com/prometheus/procfs v0.6.0 // indirect
47+
github.com/spf13/pflag v1.0.5 // indirect
48+
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
49+
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
50+
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
51+
golang.org/x/text v0.3.6 // indirect
52+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
53+
google.golang.org/api v0.58.0 // indirect
54+
google.golang.org/appengine v1.6.7 // indirect
55+
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
56+
google.golang.org/protobuf v1.27.1 // indirect
57+
gopkg.in/inf.v0 v0.9.1 // indirect
58+
gopkg.in/yaml.v2 v2.4.0 // indirect
59+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
60+
k8s.io/klog/v2 v2.20.0 // indirect
61+
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect
62+
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect
63+
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
64+
sigs.k8s.io/yaml v1.2.0 // indirect
65+
)

0 commit comments

Comments
 (0)