From 2689a5af88e9efacd144f0093687845b0bc26849 Mon Sep 17 00:00:00 2001 From: Martin Honermeyer Date: Mon, 26 May 2014 01:20:02 +0200 Subject: [PATCH 1/4] Add improved Dockerfile with wrapper script for seamless upgrades --- Dockerfile | 45 +++++++++++++++++------------------------ README.md | 13 +++++++----- docker-container | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 32 deletions(-) create mode 100755 docker-container diff --git a/Dockerfile b/Dockerfile index b0f1b829..5383362d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,25 @@ # # Dockerfile for building Twister peer-to-peer micro-blogging # +FROM ubuntu:14.04 -FROM debian:testing -MAINTAINER Álvaro Justen +# Install twister-core +RUN apt-get update +RUN apt-get install -y git autoconf libtool build-essential libboost-all-dev libssl-dev libdb++-dev libminiupnpc-dev && apt-get clean +#RUN git clone https://github.com/miguelfreitas/twister-core.git +ADD . /twister-core +RUN cd twister-core && \ + ./bootstrap.sh && \ + make -ENV DEBIAN_FRONTEND noninteractive +# Install twister-html +RUN git clone https://github.com/miguelfreitas/twister-html.git /twister-html -# Update repositories -RUN echo 'deb http://http.debian.net/debian testing main contrib' > /etc/apt/sources.list -RUN echo 'deb http://http.debian.net/debian testing-updates main contrib' >> /etc/apt/sources.list -RUN echo 'deb http://security.debian.org testing/updates main contrib' >> /etc/apt/sources.list -RUN apt-get update +# Configure HOME directory +# and persist twister data directory as a volume +ENV HOME /root +VOLUME /root/.twister -# Install needed packages to build and run twisterd -RUN apt-get -y install \ - git autoconf libtool build-essential \ - libboost-all-dev libdb++-dev libminiupnpc-dev libssl-dev - -# Clean APT cache to save disk space -RUN apt-get clean - -# Download and build twister -RUN mkdir /root/.twister -RUN git clone https://github.com/miguelfreitas/twister-core.git /root/twister-core -RUN git clone https://github.com/miguelfreitas/twister-html.git /root/.twister/html -RUN cd /root/twister-core && ./bootstrap.sh -RUN cd /root/twister-core && make - -EXPOSE 28332 -ENTRYPOINT ["/root/twister-core/twisterd"] -CMD ["-rpcuser=user", "-rpcpassword=pwd", "-rpcallowip=*", \ - "-datadir=/root/.twister", "-htmldir=/root/.twister/html"] +# Run twisterd by default +CMD ["/twister-core/twisterd", "-rpcuser=user", "-rpcpassword=pwd", "-rpcallowip=172.17.42.1", "-htmldir=/twister-html", "-printtoconsole"] +EXPOSE 28332 diff --git a/README.md b/README.md index a0837b09..ebf881ca 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,15 @@ Please follow the instructions for your platform: - [Mac OS X](https://github.com/miguelfreitas/twister-core/blob/master/doc/build-osx.md) - [Windows (untested)](https://github.com/miguelfreitas/twister-core/wiki/Compiling-for-Windows) -Or, alternatively, you can build Twister on an isolated Linux container, using -[docker](http://docker.io/): +Or, alternatively, you can run Twister on an isolated Linux container, using [docker](http://docker.io/). Quickstart: - docker build -t twister https://raw.githubusercontent.com/miguelfreitas/twister-core/master/Dockerfile - docker run -d -p 127.0.0.1:1234:28332 twister - # now try to access http://127.0.0.1:1234/ on docker host + # Prepend "sudo -E" if you are not logged in as root + ./docker-container run --remote + +The above command downloads and runs a [pre-built image](https://index.docker.io/u/mazzolino/twister/) from the Docker index. You can also build and run your own container: + + ./docker-container build + ./docker-container run > According to our tests, at least 1GB of RAM is needed to compile Twister. diff --git a/docker-container b/docker-container new file mode 100755 index 00000000..521c7b1b --- /dev/null +++ b/docker-container @@ -0,0 +1,52 @@ +#!/bin/sh +# +# Build or run a docker image of twister +# + +ACTION=${1:-run} +MODE=${2:---local} + +IMAGE_NAME=twister +REMOTE_IMAGE_NAME=mazzolino/twister + +set -e + +case $ACTION in + +build) + echo Building $IMAGE_NAME + docker build -t $IMAGE_NAME . + ;; + +run) + if [ $MODE == "--remote" ]; then + IMAGE_NAME=$REMOTE_IMAGE_NAME + fi + echo Running $IMAGE_NAME + docker run -d -p 28332:28332 -v $HOME/.twister:/root/.twister $IMAGE_NAME + echo Twister should now be running at http://localhost:28332 + ;; + +stop) + CID=$(docker ps | grep twister | awk '{print $1}') + if [ "$CID" ]; then + echo Stopping container $CID + docker stop $CID + docker rm $CID + fi + ;; + +*) + echo Usage: + echo " $0 run" + echo " Run twister from a local docker build (default)" + echo + echo " $0 run --remote" + echo " Run twister from the remote docker build at \"$REMOTE_IMAGE_NAME\"" + echo + echo " $0 build" + echo " Build a local docker image for twister" + + exit 2 + +esac From 9eaf6ebc3b3985dc9793b7971439c503ab3f0cd4 Mon Sep 17 00:00:00 2001 From: Martin Honermeyer Date: Mon, 26 May 2014 10:25:25 +0200 Subject: [PATCH 2/4] Pull the newest image before running Twister from the remote docker image --- docker-container | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-container b/docker-container index 521c7b1b..68ff06ea 100755 --- a/docker-container +++ b/docker-container @@ -21,6 +21,8 @@ build) run) if [ $MODE == "--remote" ]; then IMAGE_NAME=$REMOTE_IMAGE_NAME + echo Pulling new version of $IMAGE_NAME + docker pull $IMAGE_NAME fi echo Running $IMAGE_NAME docker run -d -p 28332:28332 -v $HOME/.twister:/root/.twister $IMAGE_NAME From 6fd09eba18ecbc174f94946ac0b6e15a997d3a42 Mon Sep 17 00:00:00 2001 From: Martin Honermeyer Date: Sat, 31 May 2014 19:32:01 +0200 Subject: [PATCH 3/4] Rename `docker-container` script to `twister-on-docker` --- README.md | 6 +++--- docker-container => twister-on-docker | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename docker-container => twister-on-docker (100%) diff --git a/README.md b/README.md index ebf881ca..dfdfab88 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,12 @@ Please follow the instructions for your platform: Or, alternatively, you can run Twister on an isolated Linux container, using [docker](http://docker.io/). Quickstart: # Prepend "sudo -E" if you are not logged in as root - ./docker-container run --remote + ./twister-on-docker run --remote The above command downloads and runs a [pre-built image](https://index.docker.io/u/mazzolino/twister/) from the Docker index. You can also build and run your own container: - ./docker-container build - ./docker-container run + ./twister-on-docker build + ./twister-on-docker run > According to our tests, at least 1GB of RAM is needed to compile Twister. diff --git a/docker-container b/twister-on-docker similarity index 100% rename from docker-container rename to twister-on-docker From 915bebd2880366ebe7c716e7e40dff33bed58778 Mon Sep 17 00:00:00 2001 From: Martin Honermeyer Date: Thu, 3 Jul 2014 00:30:24 +0200 Subject: [PATCH 4/4] [docker] Use twisterd commandline as ENTRYPOINT instead of CMD - allows running the container with additional command line parameters --- Dockerfile | 2 +- twister-on-docker | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5383362d..e6c743ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,5 +21,5 @@ ENV HOME /root VOLUME /root/.twister # Run twisterd by default -CMD ["/twister-core/twisterd", "-rpcuser=user", "-rpcpassword=pwd", "-rpcallowip=172.17.42.1", "-htmldir=/twister-html", "-printtoconsole"] +ENTRYPOINT ["/twister-core/twisterd", "-rpcuser=user", "-rpcpassword=pwd", "-rpcallowip=172.17.42.1", "-htmldir=/twister-html", "-printtoconsole"] EXPOSE 28332 diff --git a/twister-on-docker b/twister-on-docker index 68ff06ea..bbe91c8c 100755 --- a/twister-on-docker +++ b/twister-on-docker @@ -11,6 +11,8 @@ REMOTE_IMAGE_NAME=mazzolino/twister set -e +shift + case $ACTION in build) @@ -20,12 +22,13 @@ build) run) if [ $MODE == "--remote" ]; then + shift IMAGE_NAME=$REMOTE_IMAGE_NAME echo Pulling new version of $IMAGE_NAME docker pull $IMAGE_NAME fi echo Running $IMAGE_NAME - docker run -d -p 28332:28332 -v $HOME/.twister:/root/.twister $IMAGE_NAME + docker run -d -p 28332:28332 -v $HOME/.twister:/root/.twister $IMAGE_NAME "$@" echo Twister should now be running at http://localhost:28332 ;; @@ -40,10 +43,10 @@ stop) *) echo Usage: - echo " $0 run" + echo " $0 run [ARGS FOR TWISTERD..]" echo " Run twister from a local docker build (default)" echo - echo " $0 run --remote" + echo " $0 run --remote [ARGS FOR TWISTERD..]" echo " Run twister from the remote docker build at \"$REMOTE_IMAGE_NAME\"" echo echo " $0 build"