Skip to content

Commit

Permalink
Upgrade project (#16)
Browse files Browse the repository at this point in the history
* Update update workflow

* Update README

* Update CI workflow

* Fix CI workflow

* Update README and bump project version to 1.2.1

* Rename tag nightly to weekly
  • Loading branch information
tschaffter authored Jul 5, 2021
1 parent 6c97fa9 commit ec756fc
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 64 deletions.
File renamed without changes.
103 changes: 60 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
push:
branches:
- main
- develop
tags:
- '*.*.*'
pull_request:
Expand All @@ -15,87 +14,105 @@ env:
docker_repository: tschaffter/dnsmasq

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint Dockerfiles
uses: docker://hadolint/hadolint:latest
with:
entrypoint: hadolint
args: Dockerfile
- name: Validate docker-compose.yml
run: |
docker-compose -f docker-compose.yml config >/dev/null
docker:
needs: [lint]
configure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare
id: prep
- name: Create configuration
run: |
DOCKER_IMAGE=${{ env.docker_repository }}
VERSION=noop
PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
VERSION=weekly
PUSH=true
elif [[ $GITHUB_REF == refs/tags/* ]]; then
# VERSION=${GITHUB_REF#refs/tags/}
VERSION=$(cat DNSMASQ_VERSION)
# VERSION=${GITHUB_REF#refs/tags/} # use Dnsmasq version instead
VERSION=$(cat .dnsmasq-version)
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
PUSH=true
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
if [[ "$VERSION" =~ ^[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MAJOR=${VERSION%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}-${GITHUB_SHA::8}"
PUSH=true
# elif [ "${{ github.event_name }}" = "push" ]; then
# TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
elif [ "$VERSION" = "edge" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:edge-${GITHUB_SHA::8}"
PUSH=true
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=push::${PUSH}
printf "%s\n" \
"version=${VERSION}" \
"tags=${TAGS}" \
"created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
"push=${PUSH}" | tee -a .github_env
- name: Upload .github_env
uses: actions/upload-artifact@v2
with:
name: GITHUB_ENV
path: .github_env

lint:
needs: [configure]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Lint Dockerfiles
uses: docker://hadolint/hadolint:latest
with:
entrypoint: hadolint
args: Dockerfile

- name: Validate docker-compose.yml
run: |
docker-compose -f docker-compose.yml config >/dev/null
docker:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Download .github_env
uses: actions/download-artifact@v2
with:
name: GITHUB_ENV
path: .

- name: Restore $GITHUB_ENV
run: cat .github_env >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Login to DockerHub
if: steps.prep.outputs.push == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: ${{ steps.prep.outputs.push }}
tags: ${{ steps.prep.outputs.tags }}
push: ${{ env.push }}
tags: ${{ env.tags }}
labels: |
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.created=${{ env.created }}
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.version=${{ env.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.name }}
# - name: Docker Hub Description
# if: steps.prep.outputs.push == 'true'
# uses: peter-evans/dockerhub-description@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
# repository: ${{ env.docker_repository }}
16 changes: 10 additions & 6 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
name: Update project release
name: Update to latest Dnsmasq version

on:
schedule:
- cron: '0 10 * * 0' # every Sunday at 10am

jobs:
check-and-update:
name: Check and update Dnsmasq release
name: Check and update Dnsmasq
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Get latest Dnsmasq release version

- name: Get the latest release version of Dnsmasq
run: |
git clone git://thekelleys.org.uk/dnsmasq.git
cd dnsmasq
new_version=$(git describe --abbrev=0 --exclude '*rc*' --exclude '*test*')
# Trim leading 'v' in semantic version
new_version=${new_version:1}
echo "NEW_VERSION=$(echo $new_version)" >> $GITHUB_ENV
- name: Update Dnsmasq config example
run: |
cp dnsmasq/dnsmasq.conf.example ../dnsmasq.conf.example
rm -fr dnsmasq
- name: Update Docker image version
- name: Update Dnsmasq version
run: |
current_version=$(cat DNSMASQ_VERSION)
for f in DNSMASQ_VERSION Dockerfile docker-compose.yml; do
current_version=$(cat .dnsmasq-version)
for f in .dnsmasq-version README Dockerfile docker-compose.yml; do
sed -i "s/${current_version}/${{env.NEW_VERSION}}/g" "$f"
done
- name: Send pull request to update to new version
uses: peter-evans/create-pull-request@v3
with:
Expand Down
50 changes: 35 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

[![GitHub Release](https://img.shields.io/github/release/tschaffter/dnsmasq.svg?include_prereleases&color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/dnsmasq/releases)
[![GitHub CI](https://img.shields.io/github/workflow/status/tschaffter/dnsmasq/CI.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/dnsmasq/actions)
[![GitHub License](https://img.shields.io/github/license/tschaffter/dnsmasq.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/dnsmasq/blob/develop/LICENSE)
[![GitHub License](https://img.shields.io/github/license/tschaffter/dnsmasq.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/tschaffter/dnsmasq/blob/main/LICENSE)
[![Docker Pulls](https://img.shields.io/docker/pulls/tschaffter/dnsmasq.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/tschaffter/dnsmasq)

Docker image for Dnsmasq

## Overview
## Introduction

[Dnsmasq] is a lightweight, easy to configure DNS forwarder, designed to provide
DNS (and optionally DHCP and TFTP) services to a small-scale network. It can
also serve the names of local machines which are not in the global DNS.If you
own an Asus router, it is possible that [your Asus router is using Dnsmasq].


## Features

This repository:
Expand All @@ -25,6 +25,19 @@ This repository:
Docker container (e.g. [tschaffter/getdns-stubby]), which is not (yet?)
supported natively by Dnsmasq.


## Specification

- Dnsmasq version: 2.85
- Project version: 1.2.1
- Docker image: [tschaffter/dnsmasq]


## Requirements

- [Docker Engine] >=19.03.0


## Usage

### Configuration
Expand Down Expand Up @@ -65,10 +78,13 @@ arguments.
Start the Dnsmasq server. Add the option `-d` or `--detach` to run in the
background.

docker-compose up --build
```console
docker compose up
```

To stop the server, enter `Ctrl+C` followed by `docker compose down`. If running
in detached mode, you will only need to enter `docker compose down`.

To stop the server, enter `Ctrl+C` followed by `docker-compose down`. If running
in detached mode, you will only need to enter `docker-compose down`.

## Resolving domain names

Expand Down Expand Up @@ -107,6 +123,7 @@ the first lookup, and all subsequent lookups don't take any time because they
are served from the cache. For more information on how to configure Dnsmasq
cache, please read the article [How to Do DNS Caching with dnsmasq].


## Resolving a local domain name

See example specified in
Expand All @@ -124,6 +141,7 @@ myhost.example.com. 0 IN A 192.168.1.10
We can see above that the host name `myhost.example.com` has been successfully
resolved to the local IP address `192.168.1.10`.


## Versioning

### GitHub tags
Expand All @@ -136,18 +154,19 @@ always point to the same git commit once it has been created.

The artifact published by this repository is a Docker image. The versions of the
image are aligned with the versions of Dnsmasq, not the GitHub tags of this
repository. The motivation behind this strategy is that the tag directly informs
the user on the version of Dnsmasq that is being deployed.
repository. The motivation behind this strategy is that this project is mainly a
wrapper for Dnsmasq and that it is more informative to the user to use a Docker
image tag that correspond to the version of Dnsmasq being deployed.

The table below describes the image tags available.

| Tag name | Moving | Description |
|---|---|---|
| `latest` | Yes | Latest stable release |
| `edge` | Yes | Lastest commit made to the default branch |
| `<major>` | Yes | Latest stable release for the Dnsmasq major version `<major>` |
| `<major>.<minor>` | Yes | Latest stable release for the Dnsmasq version `<major>.<minor>` |
| `<major>.<minor>-<sha>` | No | Same as above but with the reference to the git commit |
| Tag name | Moving | Description
|-----------------------------|--------|------------
| `latest` | Yes | Latest stable release.
| `edge` | Yes | Latest commit made to the default branch.
| `edge-<sha>` | No | Same as above with the reference to the git commit.
| `<major>.<minor>` | No | Stable release.
| `<major>.<minor>-<sha>` | No | Same as above with the reference to the git commit.

You should avoid using a moving tag like `latest` when deploying containers in
production, because this makes it hard to track which version of the image is
Expand All @@ -164,6 +183,7 @@ then it makes sense to use a moving tag.
[Dnsmasq]: https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=summary
[your Asus router is using Dnsmasq]: https://unfinishedbitness.info/2015/05/26/asuswrt-finalized-setup/
[Stubby]: https://github.com/getdnsapi/stubby
[tschaffter/dnsmasq]: https://hub.docker.com/repository/docker/tschaffter/dnsmasq
[Dig]: https://en.wikipedia.org/wiki/Dig_(command)
[semantic versioning]: https://semver.org/
[tschaffter/getdns-stubby]: https://github.com/tschaffter/getdns-stubby
Expand Down

0 comments on commit ec756fc

Please sign in to comment.