new building and packaging

indexv1
Jakub Matys 2018-04-10 11:53:33 +02:00
parent 189c2cb24c
commit 7308bcf51a
34 changed files with 352 additions and 28 deletions

17
Makefile 100644
View File

@ -0,0 +1,17 @@
PACKAGER = $(shell id -u):$(shell id -g)
.PHONY: build test deb
build:
docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out blockbook-build make build
strip build/blockbook
test:
docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src blockbook-build make test
deb:
docker run -t --rm -e PACKAGER=$(PACKAGER) -v $(CURDIR):/src -v $(CURDIR)/build:/out blockbook-build-deb
clean:
rm -f build/blockbook
rm -f build/*.deb

View File

@ -26,14 +26,8 @@ RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make static_lib
RUN go get github.com/golang/dep/cmd/dep
# clone repo and ensure dependencies
RUN cd $GOPATH/src && git clone https://github.com/jpochyla/blockbook.git
RUN cd $GOPATH/src/blockbook && dep ensure
ADD Makefile /build/Makefile
# install gorocksdb
RUN cd $GOPATH/src/blockbook/vendor/github.com/tecbot/gorocksdb && \
go install .
VOLUME /out
WORKDIR $GOPATH/src/blockbook
CMD go build -o /out/blockbook
WORKDIR /build

12
build/bin/Makefile 100644
View File

@ -0,0 +1,12 @@
build: prepare-sources
cd $(GOPATH)/src/blockbook && go build -o $(CURDIR)/blockbook
cp $(CURDIR)/blockbook /out/blockbook
chown $(PACKAGER) /out/blockbook
test: prepare-sources
cd $(GOPATH)/src/blockbook && go test -v ./bchain/coins/zec
prepare-sources:
@ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1)
cp -r /src $(GOPATH)/src/blockbook
cd $(GOPATH)/src/blockbook && dep ensure -vendor-only

View File

@ -0,0 +1,12 @@
# initialize from the image
FROM blockbook-build:latest
RUN apt-get update && apt-get install -y \
devscripts debhelper make dh-systemd dh-exec
ADD build-deb.sh /build/build-deb.sh
WORKDIR /build
CMD /build/build-deb.sh

View File

@ -0,0 +1,10 @@
#!/bin/bash
set -e
cp -r /src/build/deb/debian .
cp -r /src/configs .
mkdir server && cp /src/server/testcert.* server
dpkg-buildpackage -us -uc
mv ../*.deb /out
chown $PACKAGER /out/*.deb

View File

@ -0,0 +1 @@
/opt/blockbook/btc-testnet/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/data/btc-testnet/blockbook
/opt/blockbook/btc-testnet/logs

View File

@ -0,0 +1,4 @@
#!/usr/bin/dh-exec
blockbook /opt/blockbook/btc-testnet/bin
server/testcert.* /opt/blockbook/btc-testnet/cert
configs/btc-testnet.json => /opt/blockbook/btc-testnet/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/opt/blockbook/btc-testnet/cert/testcert.crt /opt/blockbook/btc-testnet/cert/blockbook.crt
/opt/blockbook/btc-testnet/cert/testcert.key /opt/blockbook/btc-testnet/cert/blockbook.key

View File

@ -0,0 +1,9 @@
/opt/blockbook/btc-testnet/logs/blockbook.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook &> /dev/null
then
useradd --system -M -U blockbook
fi
if [ "$(stat -c '%U' /data/btc-testnet/blockbook)" != "blockbook" ]
then
chown -R blockbook:blockbook /data/btc-testnet/blockbook
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit blockbook-btc-testnet.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (BTC testnet)
After=network.target
[Service]
ExecStart=/opt/blockbook/btc-testnet/bin/blockbook -coin=btc-testnet -blockchaincfg=/opt/blockbook/btc-testnet/config/blockchaincfg.json -datadir=/data/btc-testnet/blockbook/db -sync -httpserver=:18335 -socketio=:18336 -certfile=/opt/blockbook/btc-testnet/cert/blockbook -explorer=https://bitcore1.trezor.io/
# Creates /run/blockbook owned by blockbook
RuntimeDirectory=blockbook
User=blockbook
# Type=forking
# PIDFile=/run/bitcoind/btc-testnet.pid
Restart=on-failure
StandardOutput=file:/opt/blockbook/btc-testnet/logs/blockbook.log
StandardError=file:/opt/blockbook/btc-testnet/logs/blockbook.log
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
/opt/blockbook/btc/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/data/btc/blockbook
/opt/blockbook/btc/logs

View File

@ -0,0 +1,4 @@
#!/usr/bin/dh-exec
blockbook /opt/blockbook/btc/bin
server/testcert.* /opt/blockbook/btc/cert
configs/btc.json => /opt/blockbook/btc/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/opt/blockbook/btc/cert/testcert.crt /opt/blockbook/btc/cert/blockbook.crt
/opt/blockbook/btc/cert/testcert.key /opt/blockbook/btc/cert/blockbook.key

View File

@ -0,0 +1,9 @@
/opt/blockbook/btc/logs/blockbook.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook &> /dev/null
then
useradd --system -M -U blockbook
fi
if [ "$(stat -c '%U' /data/btc/blockbook)" != "blockbook" ]
then
chown -R blockbook:blockbook /data/btc/blockbook
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit blockbook-btc.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (BTC mainnet)
After=network.target
[Service]
ExecStart=/opt/blockbook/btc/bin/blockbook -coin=btc -blockchaincfg=/opt/blockbook/btc/config/blockchaincfg.json -datadir=/data/btc/blockbook/db -sync -httpserver=:8335 -socketio=:8336 -certfile=/opt/blockbook/btc/cert/blockbook -explorer=https://bitcore1.trezor.io/
# Creates /run/blockbook owned by blockbook
RuntimeDirectory=blockbook
User=blockbook
# Type=forking
# PIDFile=/run/bitcoind/btc.pid
Restart=on-failure
StandardOutput=file:/opt/blockbook/btc/logs/blockbook.log
StandardError=file:/opt/blockbook/btc/logs/blockbook.log
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
/opt/blockbook/zec/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/data/zec/blockbook
/opt/blockbook/zec/logs

View File

@ -0,0 +1,4 @@
#!/usr/bin/dh-exec --with=install
blockbook /opt/blockbook/zec/bin
server/testcert.* /opt/blockbook/zec/cert
configs/zec.json => /opt/blockbook/zec/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
/opt/blockbook/zec/cert/testcert.crt /opt/blockbook/zec/cert/blockbook.crt
/opt/blockbook/zec/cert/testcert.key /opt/blockbook/zec/cert/blockbook.key

View File

@ -0,0 +1,9 @@
/opt/blockbook/zec/logs/blockbook.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook &> /dev/null
then
useradd --system -M -U blockbook
fi
if [ "$(stat -c '%U' /data/zec/blockbook)" != "blockbook" ]
then
chown -R blockbook:blockbook /data/zec/blockbook
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit blockbook-zec.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (ZEC mainnet)
After=network.target
[Service]
ExecStart=/opt/blockbook/zec/bin/blockbook -coin=zec -blockchaincfg=/opt/blockbook/zec/config/blockchaincfg.json -datadir=/data/zec/blockbook/db -sync -httpserver=:8235 -socketio=:8236 -certfile=/opt/blockbook/zec/cert/blockbook -explorer=https://zec-bitcore1.trezor.io/
# Creates /run/blockbook owned by blockbook
RuntimeDirectory=blockbook
User=blockbook
# Type=forking
# PIDFile=/run/bitcoind/zec.pid
Restart=on-failure
StandardOutput=file:/opt/blockbook/zec/logs/blockbook.log
StandardError=file:/opt/blockbook/zec/logs/blockbook.log
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,5 @@
blockbook (0.0.1-satoshilabs1) unstable; urgency=medium
* Initial build
-- Jakub Matys <jakub.matys@satoshilabs.com> Fri, 06 Apr 2018 12:44:25 +0200

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,21 @@
Source: blockbook
Section: satoshilabs
Priority: optional
Maintainer: jakub.matys@satoshilabs.com
Build-Depends: debhelper, dh-systemd, dh-exec
Standards-Version: 3.9.5
Package: blockbook-btc
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Satoshilabs blockbook server
Package: blockbook-btc-testnet
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Satoshilabs blockbook server
Package: blockbook-zec
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Satoshilabs blockbook server

View File

@ -0,0 +1,9 @@
#!/usr/bin/make -f
DH_VERBOSE = 1
%:
dh $@ --with=systemd
override_dh_strip:
dh_strip --no-automatic-dbgsym

View File

@ -1,8 +1,8 @@
{
"rpcURL": "http://localhost:8332",
"rpcURL": "http://localhost:18332",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://127.0.0.1:28332"
}
"zeroMQBinding": "tcp://127.0.0.1:18334"
}

8
configs/btc.json 100644
View File

@ -0,0 +1,8 @@
{
"rpcURL": "http://127.0.0.1:8332",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://127.0.0.1:8334"
}

8
configs/zec.json 100644
View File

@ -0,0 +1,8 @@
{
"rpcURL": "http://127.0.0.1:8232",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://127.0.0.1:8234"
}

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
cd `dirname $0`
# prepare build image
docker build -t blockbook-build .
if [ "$1" == "local" ]; then
SRC_BIND="-v $(pwd)/..:/go/src/blockbook"
fi
# build binary
docker run -t --rm -v $(pwd):/out $SRC_BIND blockbook-build
strip blockbook