Skip to content

Commit 8bec8a7

Browse files
committed
coredns(plugin+ci): Add build image job for coredns plugin
Adds a anew buid images github action for the kuadrant CoreDNS plugin. Add coredns_plugin to branches (DO NOT MERGE) Signed-off-by: Michael Nairn <[email protected]>
1 parent 65fd94c commit 8bec8a7

File tree

2 files changed

+105
-3
lines changed

2 files changed

+105
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Build and Publish CoreDNS Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- coredns_plugin
8+
- "release-*"
9+
workflow_dispatch:
10+
11+
env:
12+
IMG_TAGS: ${{ github.sha }} ${{ github.ref_name }}
13+
IMG_REGISTRY_HOST: quay.io
14+
IMG_REGISTRY_ORG: kuadrant
15+
IMG_REGISTRY_REPO: coredns-kuadrant
16+
MAIN_BRANCH_NAME: main
17+
COREDNS_PLUGIN_NAME: coredns-kuadrant
18+
19+
jobs:
20+
build:
21+
name: Build and Push CoreDNS image
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check out code
25+
uses: actions/checkout@v4
26+
27+
- name: Add latest tag
28+
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
29+
id: add-latest-tag
30+
run: |
31+
echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
32+
33+
- name: Install qemu dependency
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y qemu-user-static
37+
38+
- name: Run make coredns-generate-demo-geo-db
39+
run: |
40+
make coredns-generate-demo-geo-db
41+
42+
- name: Build Image
43+
id: build-image
44+
uses: redhat-actions/buildah-build@v2
45+
with:
46+
image: ${{ env.COREDNS_PLUGIN_NAME }}
47+
tags: ${{ env.IMG_TAGS }}
48+
platforms: linux/amd64,linux/arm64
49+
context: ./coredns/plugin
50+
dockerfiles: |
51+
./coredns/plugin/Dockerfile
52+
53+
- name: Print Build Info
54+
run: echo "Image = ${{ steps.build-image.outputs.image }}, Tags = ${{ steps.build-image.outputs.tags }}"
55+
56+
- name: Push Image
57+
if: github.repository_owner == 'kuadrant'
58+
id: push-to-quay
59+
uses: redhat-actions/push-to-registry@v2
60+
with:
61+
image: ${{ steps.build-image.outputs.image }}
62+
tags: ${{ steps.build-image.outputs.tags }}
63+
registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}
64+
username: ${{ secrets.IMG_REGISTRY_USERNAME }}
65+
password: ${{ secrets.IMG_REGISTRY_TOKEN }}
66+
67+
- name: Print Image URL
68+
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

coredns/plugin/Dockerfile

+37-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1-
FROM alpine:3.21.0
2-
COPY coredns /
1+
# Build the manager binary
2+
FROM mirror.gcr.io/library/golang:1.23 AS builder
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
6+
WORKDIR /workspace
7+
# Copy the Go Modules manifests
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
# cache deps before building and copying source so that we don't need to re-download as much
11+
# and so that source changes don't invalidate our downloaded layer
12+
RUN go mod download
13+
14+
# Copy the go source
15+
COPY cmd/coredns.go cmd/coredns.go
16+
COPY dnsop/ dnsop/
17+
COPY k8s.go k8s.go
18+
COPY kuadrant.go kuadrant.go
19+
COPY setup.go setup.go
20+
COPY weighted.go weighted.go
21+
COPY zone.go zone.go
22+
23+
# Build
24+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
25+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
26+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
27+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
28+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build cmd/coredns.go
29+
30+
# Use distroless as minimal base image to package the manager binary
31+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
32+
FROM gcr.io/distroless/static:nonroot
33+
WORKDIR /
34+
COPY --from=builder /workspace/coredns .
35+
#Copy the demo geo db
336
COPY geoip/GeoLite2-City-demo.mmdb /
4-
EXPOSE 53 53/udp
37+
USER 65532:65532
38+
539
ENTRYPOINT ["/coredns"]

0 commit comments

Comments
 (0)