Last active
April 14, 2021 04:33
-
-
Save jorijn/141f49dd0c69901f28215893d5900bca to your computer and use it in GitHub Desktop.
A Dockerfile for running the Trezor backend (blockbook) in Docker, this should be placed in the cloned git repository of https://github.com/trezor/blockbook. Configurationfile: https://gist.github.com/Jorijn/c0f5d3daf6ab6d35ac25b47c2a5be331 Docker Compose file: https://gist.github.com/Jorijn/7e1d3e7a241a98680558302a7b41586c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# initialize from the image | |
FROM debian:9 | |
RUN apt-get update && \ | |
apt-get upgrade -y && \ | |
apt-get install -y build-essential git wget pkg-config lxc-dev libzmq3-dev \ | |
libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev \ | |
liblz4-dev graphviz && \ | |
apt-get clean | |
ENV GOLANG_VERSION=go1.12.4.linux-amd64 | |
ENV ROCKSDB_VERSION=v5.18.3 | |
ENV GOPATH=/go | |
ENV PATH=$PATH:$GOPATH/bin | |
ENV CGO_CFLAGS="-I/opt/rocksdb/include" | |
ENV CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4" | |
ENV TAG=master | |
ENV USER_ID=1000 | |
RUN mkdir /build | |
# 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 -b $ROCKSDB_VERSION --depth 1 https://github.com/facebook/rocksdb.git | |
RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make -j 4 release | |
RUN strip /opt/rocksdb/ldb /opt/rocksdb/sst_dump && \ | |
cp /opt/rocksdb/ldb /opt/rocksdb/sst_dump /build | |
# install build tools | |
RUN go get github.com/golang/dep/cmd/dep | |
RUN go get github.com/gobuffalo/packr/... | |
RUN cd $GOPATH/src && git clone https://github.com/trezor/blockbook.git && cd blockbook && git checkout $TAG && dep ensure -vendor-only && \ | |
BUILDTIME=$(date --iso-8601=seconds); GITCOMMIT=$(git describe --always --dirty); \ | |
LDFLAGS="-X blockbook/common.version=${TAG} -X blockbook/common.gitcommit=${GITCOMMIT} -X blockbook/common.buildtime=${BUILDTIME}" && \ | |
go build -ldflags="-s -w ${LDFLAGS}" && rm -Rf /home/blockbook/go/pkg/dep/sources | |
RUN useradd -u $USER_ID -ms /bin/bash blockbook | |
WORKDIR $GOPATH/src/blockbook | |
RUN mkdir -p /go/src/blockbook/data && chown -R blockbook /go/src/blockbook/data | |
USER blockbook | |
EXPOSE 9030 9130 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment