-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |