Skip to content

Commit 3c2f55b

Browse files
committed
fix: container image building issue
Signed-off-by: STRRL <[email protected]>
1 parent 2eae6c1 commit 3c2f55b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33
FROM golang:1.19 AS build-env
44
ENV GO111MODULE on
55
WORKDIR /
6-
RUN git clone --depth 1 --branch v1.7.0 https://github.com/coredns/coredns
6+
RUN git clone --depth 1 --branch v1.7.1 https://github.com/coredns/coredns
77
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
8+
# RUN ln -s /k8s_dns_chaos /coredns/plugin/k8s_dns_chaos
9+
RUN echo "k8s_dns_chaos:github.com/chaos-mesh/k8s_dns_chaos" >> /coredns/plugin.cfg
10+
RUN --mount=type=cache,target=/go \
11+
cd coredns && \
12+
go mod edit -require github.com/chaos-mesh/[email protected] && \
13+
go mod edit -replace github.com/chaos-mesh/k8s_dns_chaos=/k8s_dns_chaos && \
14+
go mod edit -replace google.golang.org/grpc=google.golang.org/[email protected] && \
15+
go get github.com/chaos-mesh/k8s_dns_chaos && \
16+
go generate && \
17+
go mod tidy
18+
RUN --mount=type=cache,target=/go \
19+
cd coredns && make
1120

1221
FROM debian:stable-slim AS certs
1322
RUN apt-get update && apt-get -uy upgrade
@@ -18,4 +27,5 @@ LABEL org.opencontainers.image.source=https://github.com/chaos-mesh/k8s_dns_chao
1827
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
1928
COPY --from=build-env /coredns/coredns /coredns
2029
EXPOSE 53 53/udp
30+
ENV GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
2131
ENTRYPOINT ["/coredns"]

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ coredns: image ## Build the coredns executable binary
1010
docker container cp extract-coredns:/coredns ./coredns
1111
docker container rm -f extract-coredns
1212

13+
protoc: ## Generate the protobuf code
14+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
15+
protoc --proto_path=pb --go_out=pb --go_opt=paths=source_relative ./pb/dns.proto
16+
1317
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
1418
# 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.
1519
# More info over the usage of ANSI control characters for terminal formatting: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters

0 commit comments

Comments
 (0)