Skip to content

Commit

Permalink
fix: container image building issue
Browse files Browse the repository at this point in the history
Signed-off-by: STRRL <[email protected]>
  • Loading branch information
STRRL committed Nov 15, 2022
1 parent 2eae6c1 commit 3c2f55b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
FROM golang:1.19 AS build-env
ENV GO111MODULE on
WORKDIR /
RUN git clone --depth 1 --branch v1.7.0 https://github.com/coredns/coredns
RUN git clone --depth 1 --branch v1.7.1 https://github.com/coredns/coredns
COPY . /k8s_dns_chaos
RUN ln -s /k8s_dns_chaos /coredns/plugin/k8s_dns_chaos
RUN echo "k8s_dns_chaos:k8s_dns_chaos" >> plugin.cfg
RUN cd coredns && make
# RUN ln -s /k8s_dns_chaos /coredns/plugin/k8s_dns_chaos
RUN echo "k8s_dns_chaos:github.com/chaos-mesh/k8s_dns_chaos" >> /coredns/plugin.cfg
RUN --mount=type=cache,target=/go \
cd coredns && \
go mod edit -require github.com/chaos-mesh/[email protected] && \
go mod edit -replace github.com/chaos-mesh/k8s_dns_chaos=/k8s_dns_chaos && \
go mod edit -replace google.golang.org/grpc=google.golang.org/[email protected] && \
go get github.com/chaos-mesh/k8s_dns_chaos && \
go generate && \
go mod tidy
RUN --mount=type=cache,target=/go \
cd coredns && make

FROM debian:stable-slim AS certs
RUN apt-get update && apt-get -uy upgrade
Expand All @@ -18,4 +27,5 @@ LABEL org.opencontainers.image.source=https://github.com/chaos-mesh/k8s_dns_chao
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY --from=build-env /coredns/coredns /coredns
EXPOSE 53 53/udp
ENV GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
ENTRYPOINT ["/coredns"]
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ coredns: image ## Build the coredns executable binary
docker container cp extract-coredns:/coredns ./coredns
docker container rm -f extract-coredns

protoc: ## Generate the protobuf code
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --proto_path=pb --go_out=pb --go_opt=paths=source_relative ./pb/dns.proto

# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
# 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.
# More info over the usage of ANSI control characters for terminal formatting: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
Expand Down

0 comments on commit 3c2f55b

Please sign in to comment.