From ad2eb54ee0b0e73f651cbecf0511638f7afe0336 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 16 Dec 2014 18:31:29 +0100 Subject: [PATCH 1/4] add Dockerfile to generate docker container for influx-cli --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..345828e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM google/golang + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends libreadline-gplv2-dev + +WORKDIR /gopath/src/influx-cli +ADD . /gopath/src/influx-cli/ +RUN go get influx-cli + +CMD [] +ENTRYPOINT ["/gopath/bin/influx-cli"] From d14f0cfcc13a1be60bf59f4a9bbd142780f18630 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 17 Dec 2014 11:03:20 +0100 Subject: [PATCH 2/4] update readme with docker instructions --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index da7fb31..91cc234 100644 --- a/README.md +++ b/README.md @@ -138,3 +138,15 @@ ANY command above can be subject to: > : redirect the output into a file ``` + +docker +------ + +If you don't have a golang environment available, you can also use influx-cli +from a docker container: + +``` +$ docker build -t dieterbe/influx-cli . + +$ docker run --rm -ti dieterbe/influx-cli +``` From fb0cb1456436fcd0d7b3f971b7984951311568b4 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 17 Dec 2014 11:08:13 +0100 Subject: [PATCH 3/4] add docker-influx-cli.sh script to make it easier to run influx-cli through docker --- docker-influx-cli.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 docker-influx-cli.sh diff --git a/docker-influx-cli.sh b/docker-influx-cli.sh new file mode 100755 index 0000000..c3e768b --- /dev/null +++ b/docker-influx-cli.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +DOCKER_OPTIONS="--rm -i" +CFG="${1:-$HOME/.influxrc}" +CFGPATH=$(readlink -f "$CFG") + +if [ -f "$CFGPATH" ] +then + # add volume to influx-cli config file + DOCKER_OPTIONS="$DOCKER_OPTIONS -v $CFGPATH:/root/.influxrc" +else + >&2 echo "Cannot find influx-cli config file: $CFGPATH" +fi + +if [[ -t 0 ]] +then + # stdin is coming from the terminal + DOCKER_OPTIONS="$DOCKER_OPTIONS -t" +fi + +docker run $DOCKER_OPTIONS dieterbe/influx-cli From 00082110a03492c2a7824753e7f08510dd6c5c86 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 17 Dec 2014 11:41:08 +0100 Subject: [PATCH 4/4] update readme with docker-influx-cli.sh script doc --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 91cc234..619ed53 100644 --- a/README.md +++ b/README.md @@ -150,3 +150,25 @@ $ docker build -t dieterbe/influx-cli . $ docker run --rm -ti dieterbe/influx-cli ``` + +Once the `dieterbe/influx-cli` container has been built, you can also use the +`docker-influx-cli.sh` script to run influx-cli through docker. + +By default, `docker-influx-cli.sh` will use InfluxDB configuration from +`~/.influxrc` config file, but you can provide your own InfluxDB config file to +the script. + +Here are some usage examples: +``` +# enter influx-cli prompt with default config file +$ ./docker-influx-cli.sh + +# enter influx-cli prompt with custom my.influxrc config file +$ ./docker-influx-cli.sh my.influxrc + +# run a single query +$ echo "select * from /pattern/ limit 10" | ./docker-influx-cli.sh + +# drop all series that match a request +$ echo "list series /pattern/" | ./docker-influx-cli.sh | sed 's/.*/drop series "&"/' | ./docker-influx-cli.sh +```