Git Product home page Git Product logo

semver-dns's Introduction

semver-dns

Proof of concept semantic versioning DNS server for docker

Installation

npm install semver-dns

Description

Will make it possible to find hosts named based on semantic versioning. For example, the url http://1.3.8.test.semver will be directed to 1.3.9.test.semver (it uses the ^ range by default).

Usage

Run using docker:

DNS_CID=$(docker run -d -v /var/run/docker.sock:/var/run/docker.sock mariusgundersen/semver-dns)
DNS_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $DNS_CID)

Containers that are started and stopped while it is running will be automatically added and removed to the DNS record list.

Service provider

Start a service with a label SemVerDNS set to the hostname the container should have. The hostname has to have a TLD and cannot contain any subdomains apart from the version. The semver-dns-test-server will listen for HTTP requests and will return a json response. You can set the message using the environment variable MESSAGE. The name is optional, but is useful for starting and stopping the container

docker run -d --hostname 1.3.7.test-server.semver -e "MESSAGE=This is version 1.3.7" mariusgundersen/semver-dns-test-service
docker run -d --hostname 1.3.9.test-server.semver -e "MESSAGE=This is version 1.3.9" mariusgundersen/semver-dns-test-service

Service consumer

Service consumers need access to the dns server, so they need to be started with the dns flag pointing to the DNS server container ($DNS_IP from earlier). The mariusgundersen/semver-dns-test-client will connect to the server at SERVICE_PROVIDER using HTTP and prints the result.

docker run -it --rm --dns=$DNS_IP -e SERVICE_PROVIDER=1.3.7.test-server.semver mariusgundersen/semver-dns-test-client

Dynamic update

You can now add or remove service providers and the dns will update. For example, add 1.4.0.test-server.semver and rerun the servicue consumer

docker run -d --hostname 1.4.0.test-server.semver -e "MESSAGE=This is version 1.4.0" mariusgundersen/semver-dns-test-service
docker run -it --rm --dns=$DNS_IP -e SERVICE_PROVIDER=1.3.7.test-server.semver mariusgundersen/semver-dns-test-client
docker run -it --rm --dns=$DNS_IP -e SERVICE_PROVIDER=patch--1.3.7.test-server.semver mariusgundersen/semver-dns-test-client

Versioning rules

  • 1.3.7 is equivalent to ^1.3.7
  • patch--1.3.7 is equivalent to ~1.3.7
  • exact--1.3.7 is equivalent to 1.3.7
  • 1.3.7-beta.1 is equivalent to ^1.3.7-beta.1

semver-dns's People

Contributors

mariusgundersen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.