[feature] add option to build portable binaries (#685)
Co-authored-by: Martin <martin.boehm@1mbsoftware.net>
This commit is contained in:
parent
5802a43169
commit
fb7a71034b
3
Makefile
3
Makefile
@ -4,6 +4,7 @@ PACKAGER = $(shell id -u):$(shell id -g)
|
|||||||
BASE_IMAGE = $$(awk -F= '$$1=="ID" { print $$2 ;}' /etc/os-release):$$(awk -F= '$$1=="VERSION_ID" { print $$2 ;}' /etc/os-release | tr -d '"')
|
BASE_IMAGE = $$(awk -F= '$$1=="ID" { print $$2 ;}' /etc/os-release):$$(awk -F= '$$1=="VERSION_ID" { print $$2 ;}' /etc/os-release | tr -d '"')
|
||||||
NO_CACHE = false
|
NO_CACHE = false
|
||||||
TCMALLOC =
|
TCMALLOC =
|
||||||
|
PORTABLE = 0
|
||||||
ARGS ?=
|
ARGS ?=
|
||||||
|
|
||||||
TARGETS=$(subst .json,, $(shell ls configs/coins))
|
TARGETS=$(subst .json,, $(shell ls configs/coins))
|
||||||
@ -46,7 +47,7 @@ build-images: clean-images
|
|||||||
.bin-image:
|
.bin-image:
|
||||||
@if [ $$(build/tools/image_status.sh $(BIN_IMAGE):latest build/docker) != "ok" ]; then \
|
@if [ $$(build/tools/image_status.sh $(BIN_IMAGE):latest build/docker) != "ok" ]; then \
|
||||||
echo "Building image $(BIN_IMAGE) from $(BASE_IMAGE)"; \
|
echo "Building image $(BIN_IMAGE) from $(BASE_IMAGE)"; \
|
||||||
docker build --no-cache=$(NO_CACHE) --build-arg TCMALLOC=$(TCMALLOC) --build-arg BASE_IMAGE=$(BASE_IMAGE) -t $(BIN_IMAGE) build/docker/bin; \
|
docker build --no-cache=$(NO_CACHE) --build-arg TCMALLOC=$(TCMALLOC) --build-arg BASE_IMAGE=$(BASE_IMAGE) --build-arg PORTABLE_ROCKSDB=$(PORTABLE) -t $(BIN_IMAGE) build/docker/bin; \
|
||||||
else \
|
else \
|
||||||
echo "Image $(BIN_IMAGE) is up to date"; \
|
echo "Image $(BIN_IMAGE) is up to date"; \
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
ARG BASE_IMAGE
|
ARG BASE_IMAGE
|
||||||
FROM $BASE_IMAGE
|
FROM $BASE_IMAGE
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
ARG PORTABLE_ROCKSDB
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get upgrade -y && \
|
apt-get upgrade -y && \
|
||||||
@ -36,7 +37,7 @@ RUN echo -n "GOPATH: " && echo $GOPATH
|
|||||||
|
|
||||||
# install rocksdb
|
# install rocksdb
|
||||||
RUN cd /opt && git clone -b $ROCKSDB_VERSION --depth 1 https://github.com/facebook/rocksdb.git
|
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 cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC PORTABLE=$PORTABLE_ROCKSDB make -j 4 release
|
||||||
RUN strip /opt/rocksdb/ldb /opt/rocksdb/sst_dump && \
|
RUN strip /opt/rocksdb/ldb /opt/rocksdb/sst_dump && \
|
||||||
cp /opt/rocksdb/ldb /opt/rocksdb/sst_dump /build
|
cp /opt/rocksdb/ldb /opt/rocksdb/sst_dump /build
|
||||||
|
|
||||||
|
|||||||
@ -86,6 +86,8 @@ command: `make NO_CACHE=true all-bitcoin`.
|
|||||||
|
|
||||||
`TCMALLOC`: RocksDB, the storage engine used by Blockbook, allows to use alternative memory allocators. Use the `TCMALLOC` variable to specify Google's TCMalloc allocator `make TCMALLOC=true all-bitcoin`. To run Blockbook built with TCMalloc, the library must be installed on the target server, for example by `sudo apt-get install google-perftools`.
|
`TCMALLOC`: RocksDB, the storage engine used by Blockbook, allows to use alternative memory allocators. Use the `TCMALLOC` variable to specify Google's TCMalloc allocator `make TCMALLOC=true all-bitcoin`. To run Blockbook built with TCMalloc, the library must be installed on the target server, for example by `sudo apt-get install google-perftools`.
|
||||||
|
|
||||||
|
`PORTABLE`: By default, the RocksDB binaries shipped with Blockbook are optimized for the platform you're compiling on (-march=native or the equivalent). If you want to build a portable binary, use `make PORTABLE=1 all-bitcoin`.
|
||||||
|
|
||||||
### Naming conventions and versioning
|
### Naming conventions and versioning
|
||||||
|
|
||||||
All configuration keys described below are in coin definition file in *configs/coins*.
|
All configuration keys described below are in coin definition file in *configs/coins*.
|
||||||
@ -199,7 +201,8 @@ export PATH=$PATH:$GOPATH/bin
|
|||||||
```
|
```
|
||||||
|
|
||||||
Install RocksDB: https://github.com/facebook/rocksdb/blob/master/INSTALL.md
|
Install RocksDB: https://github.com/facebook/rocksdb/blob/master/INSTALL.md
|
||||||
and compile the static_lib and tools
|
and compile the static_lib and tools. Optionally, consider adding `PORTABLE=1` before the
|
||||||
|
make command to create a portable binary.
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo apt-get update && sudo apt-get install -y \
|
sudo apt-get update && sudo apt-get install -y \
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user