Skip to content

Commit

Permalink
feat(coredns): add image
Browse files Browse the repository at this point in the history
  • Loading branch information
f-bn committed Apr 13, 2024
1 parent 7597241 commit 7e19e4a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-coredns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Build CoreDNS image
on:
push:
branches:
- main
paths:
- 'coredns/**'
- '!coredns/README.md'
- '.github/workflows/build-coredns.yml'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
version: ['1.11.1']
steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image to registry
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: ./coredns
file: ./coredns/Dockerfile
push: true
build-args: |
VERSION=${{ matrix.version }}
tags: |
ghcr.io/f-bn/coredns:${{ matrix.version }}
42 changes: 42 additions & 0 deletions coredns/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --- Build stage ---
FROM docker.io/golang:1.20 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION=1.11.1

ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
ENV CGO_ENABLED=0

RUN set -ex ; \
export DEBIAN_FRONTEND=noninteractive ; \
apt update ; \
apt install -y --no-install-recommends libcap2-bin

WORKDIR /build

RUN git clone --single-branch --branch v${VERSION} https://github.com/coredns/coredns.git /build
RUN set -ex ; \
go build -v -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(git rev-parse HEAD)" -o /build/bin/coredns ; \
setcap cap_net_bind_service=+ep /build/bin/coredns

# --- Final stage ---
FROM cgr.dev/chainguard/wolfi-base:latest

ARG VERSION

COPY --from=build --chmod=755 /build/bin/coredns /usr/bin/coredns

USER nonroot

EXPOSE 53/tcp 53/udp

ENTRYPOINT [ "/usr/bin/coredns" ]

LABEL \
org.opencontainers.image.title="CoreDNS" \
org.opencontainers.image.source="https://github.com/f-bn/containers-images/coredns" \
org.opencontainers.image.description="CoreDNS is a DNS server that chains plugins" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.authors="Florian Bobin <[email protected]>"
5 changes: 5 additions & 0 deletions coredns/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## General informations

Custom CoreDNS image built from sources.

Built with Go 1.20.

0 comments on commit 7e19e4a

Please sign in to comment.