From 269ed97042533dabe81e5d88b94b9ce3c02464e5 Mon Sep 17 00:00:00 2001 From: slush Date: Sun, 11 Feb 2018 13:49:07 +0100 Subject: [PATCH 1/3] Docker build script --- .gitignore | 1 + docker/Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docker/build.sh | 8 ++++++++ 3 files changed, 45 insertions(+) create mode 100644 docker/Dockerfile create mode 100755 docker/build.sh diff --git a/.gitignore b/.gitignore index 688e34db..354c1aad 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ blockbook notes.txt debug .vscode +docker/blockbook diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..681ee320 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,36 @@ +# initialize from the image + +FROM debian:9 + +RUN apt-get update && apt-get install -y \ + build-essential git wget pkg-config lxc-dev libzmq3-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev + +ENV GOLANG_VERSION=go1.9.2.linux-amd64 +ENV GOPATH=/go + +# install and configure go +RUN cd /opt && wget https://storage.googleapis.com/golang/$GOLANG_VERSION.tar.gz && tar xf $GOLANG_VERSION.tar.gz +RUN ln -s /opt/go/bin/go /usr/bin/go +RUN mkdir -p $GOPATH +RUN echo -n "GO version: " && go version +RUN echo -n "GOPATH: " && echo $GOPATH + +# install rocksdb +RUN cd /opt && git clone https://github.com/facebook/rocksdb.git +RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make static_lib + +# install gorocksdb +RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4" go get github.com/tecbot/gorocksdb + +RUN go get github.com/golang/glog +RUN go get github.com/graarh/golang-socketio +RUN go get github.com/btcsuite/btcd +RUN go get github.com/gorilla/handlers +RUN go get github.com/bsm/go-vlq +RUN go get github.com/gorilla/handlers +RUN go get github.com/gorilla/mux +RUN go get github.com/pebbe/zmq4 +RUN go get github.com/pkg/profile + +RUN cd $GOPATH/src && git clone https://github.com/jpochyla/blockbook.git +RUN cd $GOPATH/src/blockbook && go build diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 00000000..2bab2016 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +cd `dirname $0` + +docker build -t blockbook-build . +docker run -t -v $(pwd):/out blockbook-build /bin/cp /go/src/blockbook/blockbook /out/ + From fb4a2ae3731e73197fa7760c22a4ae520c013506 Mon Sep 17 00:00:00 2001 From: slush Date: Sun, 11 Feb 2018 13:52:33 +0100 Subject: [PATCH 2/3] Updated dependencies in README, docker build --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99abfdf3..b6566e87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # blockbook +## Install using Docker: + +``` +git clone https://github.com/jpochyla/blockbook.git +cd blockbook/docker +./build.sh +``` + ## Install Setup go environment (Debian 9): @@ -37,10 +45,17 @@ Install Go interface to ZeroMQ: go get github.com/pebbe/zmq4 ``` -Install additional go libraries - glog logging, socket.io: +Install additional go libraries: ``` go get github.com/golang/glog go get github.com/graarh/golang-socketio +go get github.com/btcsuite/btcd +go get github.com/gorilla/handlers +go get github.com/bsm/go-vlq +go get github.com/gorilla/handlers +go get github.com/gorilla/mux +go get github.com/pebbe/zmq4 +go get github.com/pkg/profile ``` Install blockbook: From 41af370fa347c23c9e41f541df3b2b7b70f0aa6b Mon Sep 17 00:00:00 2001 From: slush Date: Sun, 11 Feb 2018 14:37:00 +0100 Subject: [PATCH 3/3] docker: Strip final binary --- docker/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/build.sh b/docker/build.sh index 2bab2016..1f9e0a4f 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -6,3 +6,4 @@ cd `dirname $0` docker build -t blockbook-build . docker run -t -v $(pwd):/out blockbook-build /bin/cp /go/src/blockbook/blockbook /out/ +strip blockbook