Skip to content

Commit 3578c2d

Browse files
committed
Add Docker support
1 parent d87054d commit 3578c2d

File tree

6 files changed

+690
-4
lines changed

6 files changed

+690
-4
lines changed

.github/workflows/go.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,27 @@
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
33

44
name: Go
5+
env:
6+
REGISTRY: ghcr.io
7+
IMAGE_NAME: ${{ github.repository }}
58

69
on:
710
push:
8-
branches: [ "master" ]
11+
branches: [ "master", "docker-support-v2" ]
912
pull_request:
1013
branches: [ "master" ]
1114

1215
jobs:
1316

1417
build:
1518
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
1623
steps:
17-
- uses: actions/checkout@v4
24+
- name: Checkout
25+
uses: actions/checkout@v4
1826

1927
- name: Set up Go
2028
uses: actions/setup-go@v4
@@ -26,3 +34,24 @@ jobs:
2634

2735
- name: Test
2836
run: go test -v ./...
37+
38+
- name: Log in to the Container registry
39+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.repository_owner }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Extract metadata (tags, labels) for Docker
46+
id: meta
47+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
53+
with:
54+
context: "cmd/coredns"
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

cmd/coredns/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM golang:1.20
2+
ENV SSL_CERT_DIR=/etc/ssl/certs
3+
RUN apt-get update && apt-get install -y ca-certificates openssl
4+
5+
6+
RUN openssl s_client -showcerts -connect github.com:443 </dev/null 2>/dev/null|openssl x509 -outform PEM > ${SSL_CERT_DIR}/github.crt
7+
RUN openssl s_client -showcerts -connect proxy.golang.org:443 </dev/null 2>/dev/null|openssl x509 -outform PEM > ${SSL_CERT_DIR}/proxy.golang.crt
8+
RUN openssl s_client -showcerts -connect sum.golang.org:443 </dev/null 2>/dev/null|openssl x509 -outform PEM > ${SSL_CERT_DIR}/sum.golang.crt
9+
# Update certificates
10+
RUN update-ca-certificates
11+
12+
COPY . /opt/coredns-drove/
13+
COPY example/Corefile /opt/coredns-drove
14+
WORKDIR /opt/coredns-drove
15+
RUN go build
16+
EXPOSE 1053 1053/udp
17+
ENTRYPOINT ["/opt/coredns-drove/coredns-drove"]

cmd/coredns/example/Corefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
cache 30
55
ready
66
forward . /etc/resolv.conf
7-
metrics
7+
prometheus
88
drove {
99
endpoint "https://drovecontrol001.exmaple.com:8080,https://drovecontrol002.exmaple.com:8080,https://drovecontrol003.exmaple.com:8080:8080"
1010
access_token "Bearer <token>"

cmd/coredns/go.mod

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
module phonepe.com/coredns-drove
2+
3+
go 1.21
4+
5+
require (
6+
github.com/PhonePe/coredns-drove v0.0.0-20240813141603-d87054dc87ee
7+
github.com/coredns/coredns v1.11.1
8+
)
9+
10+
require (
11+
cloud.google.com/go/compute v1.23.0 // indirect
12+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
13+
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
14+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
15+
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
16+
github.com/Azure/go-autorest/autorest/adal v0.9.22 // indirect
17+
github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect
18+
github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 // indirect
19+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
20+
github.com/Azure/go-autorest/autorest/to v0.2.0 // indirect
21+
github.com/Azure/go-autorest/logger v0.2.1 // indirect
22+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
23+
github.com/DataDog/appsec-internal-go v1.0.0 // indirect
24+
github.com/DataDog/datadog-agent/pkg/obfuscate v0.45.0-rc.1 // indirect
25+
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.48.0-devel.0.20230725154044-2549ba9058df // indirect
26+
github.com/DataDog/datadog-go/v5 v5.1.1 // indirect
27+
github.com/DataDog/go-libddwaf v1.4.2 // indirect
28+
github.com/DataDog/go-tuf v1.0.1-0.5.2 // indirect
29+
github.com/DataDog/sketches-go v1.2.1 // indirect
30+
github.com/Microsoft/go-winio v0.5.2 // indirect
31+
github.com/antonmedv/expr v1.13.0 // indirect
32+
github.com/apparentlymart/go-cidr v1.1.0 // indirect
33+
github.com/aws/aws-sdk-go v1.44.322 // indirect
34+
github.com/beorn7/perks v1.0.1 // indirect
35+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
36+
github.com/coredns/caddy v1.1.1 // indirect
37+
github.com/coreos/go-semver v0.3.0 // indirect
38+
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
39+
github.com/davecgh/go-spew v1.1.1 // indirect
40+
github.com/dimchansky/utfbom v1.1.1 // indirect
41+
github.com/dnstap/golang-dnstap v0.4.0 // indirect
42+
github.com/dustin/go-humanize v1.0.1 // indirect
43+
github.com/ebitengine/purego v0.5.0-alpha // indirect
44+
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
45+
github.com/farsightsec/golang-framestream v0.3.0 // indirect
46+
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
47+
github.com/go-logr/logr v1.2.4 // indirect
48+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
49+
github.com/go-openapi/jsonreference v0.20.1 // indirect
50+
github.com/go-openapi/swag v0.22.3 // indirect
51+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
52+
github.com/gogo/protobuf v1.3.2 // indirect
53+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
54+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
55+
github.com/golang/mock v1.6.0 // indirect
56+
github.com/golang/protobuf v1.5.3 // indirect
57+
github.com/google/gnostic v0.5.7-v3refs // indirect
58+
github.com/google/go-cmp v0.5.9 // indirect
59+
github.com/google/gofuzz v1.2.0 // indirect
60+
github.com/google/pprof v0.0.0-20230509042627-b1315fad0c5a // indirect
61+
github.com/google/s2a-go v0.1.4 // indirect
62+
github.com/google/uuid v1.3.0 // indirect
63+
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
64+
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
65+
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
66+
github.com/imdario/mergo v0.3.12 // indirect
67+
github.com/infobloxopen/go-trees v0.0.0-20200715205103-96a057b8dfb9 // indirect
68+
github.com/jmespath/go-jmespath v0.4.0 // indirect
69+
github.com/josharian/intern v1.0.0 // indirect
70+
github.com/json-iterator/go v1.1.12 // indirect
71+
github.com/mailru/easyjson v0.7.7 // indirect
72+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
73+
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
74+
github.com/miekg/dns v1.1.58 // indirect
75+
github.com/mitchellh/go-homedir v1.1.0 // indirect
76+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
77+
github.com/modern-go/reflect2 v1.0.2 // indirect
78+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
79+
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
80+
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect
81+
github.com/opentracing/opentracing-go v1.2.0 // indirect
82+
github.com/openzipkin-contrib/zipkin-go-opentracing v0.5.0 // indirect
83+
github.com/openzipkin/zipkin-go v0.4.2 // indirect
84+
github.com/oschwald/geoip2-golang v1.9.0 // indirect
85+
github.com/oschwald/maxminddb-golang v1.11.0 // indirect
86+
github.com/outcaste-io/ristretto v0.2.1 // indirect
87+
github.com/philhofer/fwd v1.1.2 // indirect
88+
github.com/pkg/errors v0.9.1 // indirect
89+
github.com/prometheus/client_golang v1.18.0 // indirect
90+
github.com/prometheus/client_model v0.5.0 // indirect
91+
github.com/prometheus/common v0.45.0 // indirect
92+
github.com/prometheus/procfs v0.12.0 // indirect
93+
github.com/quic-go/qtls-go1-20 v0.3.1 // indirect
94+
github.com/quic-go/quic-go v0.37.4 // indirect
95+
github.com/secure-systems-lab/go-securesystemslib v0.7.0 // indirect
96+
github.com/spf13/pflag v1.0.5 // indirect
97+
github.com/tinylib/msgp v1.1.8 // indirect
98+
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
99+
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
100+
go.etcd.io/etcd/client/v3 v3.5.9 // indirect
101+
go.opencensus.io v0.24.0 // indirect
102+
go.uber.org/atomic v1.11.0 // indirect
103+
go.uber.org/multierr v1.6.0 // indirect
104+
go.uber.org/zap v1.17.0 // indirect
105+
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
106+
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
107+
golang.org/x/crypto v0.18.0 // indirect
108+
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
109+
golang.org/x/mod v0.14.0 // indirect
110+
golang.org/x/net v0.20.0 // indirect
111+
golang.org/x/oauth2 v0.12.0 // indirect
112+
golang.org/x/sys v0.16.0 // indirect
113+
golang.org/x/term v0.16.0 // indirect
114+
golang.org/x/text v0.14.0 // indirect
115+
golang.org/x/time v0.3.0 // indirect
116+
golang.org/x/tools v0.17.0 // indirect
117+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
118+
google.golang.org/api v0.136.0 // indirect
119+
google.golang.org/appengine v1.6.7 // indirect
120+
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
121+
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect
122+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
123+
google.golang.org/grpc v1.57.0 // indirect
124+
google.golang.org/protobuf v1.31.0 // indirect
125+
gopkg.in/DataDog/dd-trace-go.v1 v1.54.0 // indirect
126+
gopkg.in/inf.v0 v0.9.1 // indirect
127+
gopkg.in/yaml.v2 v2.4.0 // indirect
128+
gopkg.in/yaml.v3 v3.0.1 // indirect
129+
inet.af/netaddr v0.0.0-20220811202034-502d2d690317 // indirect
130+
k8s.io/api v0.27.4 // indirect
131+
k8s.io/apimachinery v0.27.4 // indirect
132+
k8s.io/client-go v0.27.4 // indirect
133+
k8s.io/klog/v2 v2.100.1 // indirect
134+
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
135+
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
136+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
137+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
138+
sigs.k8s.io/yaml v1.3.0 // indirect
139+
)

0 commit comments

Comments
 (0)