Skip to content

Commit

Permalink
Added docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ameshkov committed Sep 5, 2024
1 parent 1bad4d3 commit ea3c2ca
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.x
go-version: 1.23

- name: Run tests
run: |-
Expand All @@ -49,7 +49,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.x
go-version: 1.23

- name: Prepare environment
run: |-
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker

on:
push:
tags:
- 'v*'
branches:
- 'master'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: "VERSION=${GITHUB_REF##*/}"
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ adheres to [Semantic Versioning][semver].

## [Unreleased]

### Added

* Added [Docker image][dockerimage].

[dockerimage]: https://github.com/ameshkov/godnsbench/pkgs/container/godnsbench

### Changed

* Updated dependencies
* Updated dependencies.

[unreleased]: https://github.com/ameshkov/godnsbench/compare/v1.8.1...HEAD

Expand Down
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Step 1: Use the official Golang image as the build environment.
# This image includes all the tools needed to compile Go applications.
FROM golang:1.23 as builder

# Version will be passed as a part of the build.
ARG VERSION=dev

# Set the Current Working Directory inside the container.
WORKDIR /app

# Copy the local package files to the container's workspace.
COPY . .

# Build the Go app for a Linux system.
RUN VERSION=${VERSION} make build

# Step 2: Use a builder image to get the latest certificates.
FROM alpine:latest as certs

# Download the latest CA certificates
RUN apk --update add ca-certificates

# Step 3: Use a Docker multi-stage build to create a lean production image.
# Start from a scratch (empty) image to keep the image size small.
FROM scratch

# Copy the binary from the builder stage to the production image.
COPY --from=builder /app/godnsbench /

# Copy the CA certificates from the certs image.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT ["/godnsbench"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endif
default: build

build: clean
go build -ldflags "-X main.VersionString=$(VERSION)"
CGO_ENABLED=0 go build -ldflags "-X main.VersionString=$(VERSION)"

release: check-env-release
mkdir -p $(BUILDDIR)
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@

# godnsbench

A very simple DNS benchmarking tool based on [dnsproxy](https://github.com/AdguardTeam/dnsproxy).
A very simple DNS benchmarking tool based on [dnsproxy][dnsproxy].

[dnsproxy]: https://github.com/AdguardTeam/dnsproxy

## How to install

* Using homebrew:
```
```shell
brew install ameshkov/tap/godnsbench
```
* From source:
```
```shell
go install github.com/ameshkov/godnsbench@latest
```
* You can get a binary from the [releases page](https://github.com/ameshkov/godnsbench/releases).
* You can use [a Docker image][dockerimage]:
```shell
docker run --rm ghcr.io/ameshkov/godnsbench --help
```
* You can get a binary from the [releases page][releases].

[dockerimage]: https://github.com/ameshkov/godnsbench/pkgs/container/godnsbench

[releases]: https://github.com/ameshkov/godnsbench/releases

## Usage

Expand Down Expand Up @@ -44,29 +53,34 @@ Help Options:
## Examples
10 connections, 1000 queries to Google DNS using DNS-over-TLS:
```shell
godnsbench -a tls://dns.google -p 10 -c 1000
```
10 connections, 1000 queries to Google DNS using DNS-over-HTTPS with rate limit
not higher than 10 queries per second:
```shell
godnsbench -a https://dns.google/dns-query -p 10 -c 1000 -r 10
```
10 connections, 1000 queries for `example.net` to Google DNS using DNS-over-TLS:
```shell
godnsbench -a https://dns.google/dns-query -p 10 -c 1000 -q example.net
```
10 connections, 1000 queries for `example.net` with timeout 1 second to
AdGuard DNS using DNS-over-QUIC:
```shell
godnsbench -a quic://dns.adguard.com -p 10 -c 1000 -t 1 -q example.net
```
10 connections, 1000 queries for random subdomains of `example.net` with
timeout 1 second to Google DNS using DNS-over-TLS:
```shell
godnsbench -a tls://dns.google -p 10 -c 1000 -t 1 -q {random}.example.net
```

0 comments on commit ea3c2ca

Please sign in to comment.