Browse Source

Docker image!

Signed-off-by: Erik Hollensbe <github@hollensbe.org>
master
Erik Hollensbe 10 months ago
parent
commit
d96df57bea
4 changed files with 75 additions and 0 deletions
  1. +4
    -0
      Makefile
  2. +18
    -0
      README.md
  3. +34
    -0
      box-release.rb
  4. +19
    -0
      release-entrypoint.sh

+ 4
- 0
Makefile View File

@ -1,4 +1,5 @@
IMAGE_NAME ?= ldnsd:testing
RELEASE_IMAGE_NAME ?= erikh/ldnsd:$(shell cat VERSION)
CODE_PATH ?= /go/src/github.com/erikh/ldnsd
GO_TEST := sudo go test -v ./... -race -count 1
VERSION ?= $(shell git rev-parse HEAD)
@ -19,6 +20,9 @@ release: distclean
cp README.md example.conf build/ldnsd-$$(cat VERSION)
cd build && tar cvzf ../ldnsd-$$(cat ../VERSION).tar.gz ldnsd-$$(cat ../VERSION)
release-image:
VERSION=$$(cat VERSION) box -t $(RELEASE_IMAGE_NAME) box-release.rb
distclean:
rm -rf build


+ 18
- 0
README.md View File

@ -25,6 +25,24 @@ as a companion to your DNS stack instead of replacing it.
Installing a release is your best choice. Otherwise, you can still `go get github.com/erikh/ldnsd/...`
and get the desired result in your `$GOBIN` or `$GOPATH/bin`.
### Docker Image
If you wish to use Docker to power ldnsd, you can use our `erikh/ldnsd`
version-tagged images. Running with `--net=host` is advisable to avoid the UDP
proxy docker provides as it tends to drop packets under high load.
Example usage:
```bash
# start the service
$ docker run -it -d --name ldnsd --net=host erikh/ldnsd:0.1.0
# configure some hosts
$ docker exec -it ldnsd ldnsctl set myhost 1.2.3.4
$ dig myhost.internal. @127.0.0.1
```
### Manual Installation
If you'd like to build in a container or build the release version, just make
sure to have `docker` installed; [box](https://github.com/box-builder/box) will
be installed as root as a part of the process during the first run while


+ 34
- 0
box-release.rb View File

@ -0,0 +1,34 @@
from "debian:latest"
MKCERT_VERSION = "1.4.1"
MKCERT_URL = "https://github.com/FiloSottile/mkcert/releases/download/v#{MKCERT_VERSION}/mkcert-v#{MKCERT_VERSION}-linux-amd64"
def download(name, url)
run "curl -sSL -o /#{name} '#{url}'"
yield "/#{name}"
run "rm -f /#{name}"
end
version = getenv("VERSION")
skip do
run "apt update && apt install curl -y"
download("mkcert", MKCERT_URL) do |path|
run "chmod 0755 '#{path}'"
run "mv '#{path}' /tmp/mkcert"
end
copy "ldnsd-#{version}.tar.gz", "/tmp/"
inside "/tmp" do
run "tar vxzf ldnsd-#{version}.tar.gz"
end
end
inside "/tmp/ldnsd-#{version}" do
run "mv -v ldnsd ldnsctl /usr/local/bin && mkdir -p /etc/ldnsd && mv -v example.conf /etc/ldnsd/ldnsd.conf"
end
run "mv /tmp/mkcert /usr/local/bin"
copy "release-entrypoint.sh", "/entrypoint.sh"
copy "VERSION", "/VERSION"
run "chmod 755 /entrypoint.sh"
set_exec entrypoint: ["/entrypoint.sh"], cmd: ["/usr/local/bin/ldnsd", "/etc/ldnsd/ldnsd.conf"]

+ 19
- 0
release-entrypoint.sh View File

@ -0,0 +1,19 @@
#!/bin/sh
export CAROOT=/etc/ldnsd PATH=/usr/local/bin:${PATH}
if [ ! -f "${CAROOT}/rootCA.pem" ]
then
mkcert -install
fi
if [ ! -f "${CAROOT}/server.pem" ]
then
mkcert -cert-file /etc/ldnsd/server.pem -key-file /etc/ldnsd/server.key localhost 127.0.0.1
fi
if [ ! -f "${CAROOT}/client.pem" ]
then
mkcert -client -cert-file /etc/ldnsd/client.pem -key-file /etc/ldnsd/client.key localhost 127.0.0.1
fi
exec "$@"

Loading…
Cancel
Save