From 34eeb494a69555c9c91405000be2d55182f1f766 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 21 Sep 2020 12:08:59 +0100 Subject: [PATCH 1/6] chore: add docker build and make targets - add Dockerfile to build `filecoin/sentinel-visor` docker image - add make targets to build filecoin-ffi and sentinel-visor - add .dockerignore to reduce context sent to docker build License: MIT Signed-off-by: Oli Evans --- .dockerignore | 7 +++++++ Dockerfile | 19 +++++++++++++++++++ Makefile | 35 +++++++++++++++++++++++++++++++++++ README.md | 15 +++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ad93c6be3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +/.circleci +/.github +/extern/filecoin-ffi +/visor +/Dockerfile* +/docker-compose* +/sentinel-visor \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c2e2a882d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# Builder +FROM golang:1.14.9 as builder + +# Install deps for filecoin-project/filecoin-ffi +RUN apt-get update +RUN apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev + +WORKDIR /go/src/github.com/filecoin-project/sentinel-visor +COPY . /go/src/github.com/filecoin-project/sentinel-visor +RUN make build + +# Runner +FROM buildpack-deps:buster-curl +# Grab the things +COPY --from=builder /go/src/github.com/filecoin-project/sentinel-visor/sentinel-visor /usr/bin/ +COPY --from=builder /usr/lib/x86_64-linux-gnu/libOpenCL.so* /lib/ + +ENTRYPOINT ["/usr/bin/sentinel-visor"] +CMD ["--help"] \ No newline at end of file diff --git a/Makefile b/Makefile index a1f099e18..d27296c24 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,28 @@ PG_IMAGE?=postgres:10 REDIS_IMAGE?=redis:6 +COMMIT := $(shell git rev-parse --short HEAD) + +unexport GOFLAGS + +BINS:= + +GOFLAGS:= + +.PHONY: all +all: build + +.PHONY: build +build: sentinel-visor .PHONY: deps deps: git submodule update --init --recursive +.PHONY: sentinel-visor +sentinel-visor: extern/filecoin-ffi/.install-filcrypto + rm -f ./sentinel-visor + go build -o sentinel-visor . + # test starts dependencies and runs all tests .PHONY: test test: dockerup testfull dockerdown @@ -26,3 +44,20 @@ testfull: .PHONY: testshort testshort: go test -short ./... -v + +# only build filecoin-ffi if .install-filcrypto is missing +extern/filecoin-ffi/.install-filcrypto: deps + $(MAKE) -C extern/filecoin-ffi + +.PHONY: sentinel-visor +sentinel-visor: extern/filecoin-ffi/.install-filcrypto + rm -f sentinel-visor + go build $(GOFLAGS) -o sentinel-visor . + +BINS+=sentinel-visor + +.PHONY: docker-image +docker-image: + docker build -t "filecoin/sentinel-visor" . + docker tag "filecoin/sentinel-visor:latest" "filecoin/sentinel-visor:$(COMMIT)" + diff --git a/README.md b/README.md index 91f021c37..fb90416ff 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ A **Visor** process collects _permanent_ Filecoin chain meterics from a [**Lotus ## Getting Started +Clone the repo and run `make build`: + +```console +$ git clone git@github.com:filecoin-project/sentinel-visor.git +$ cd sentinel-visor +$ make build +``` + +This will fetch the git modules, build the filecoin-ffi, and build a `sentinel-visor` binary to the root of the project directory. + ### Usage ``` @@ -16,6 +26,11 @@ A **Visor** process collects _permanent_ Filecoin chain meterics from a [**Lotus Use 'sentinel-visor help ' to learn more about each command. ``` +Use the following env vars to configure the lotus node that visor reads from, and the database that it writes to: + +- `LOTUS_PATH` - path to the lotus data dir. _default: `~/.lotus`_ +- `LOTUS_DB` - database connection . _default: `postgres://postgres:password@localhost:5432/postgres?sslmode=disable`_ + ### Configuring Tracing The global flag `--tracing=` turns tracing on or off. It is on by default. From 1547b49a2468e401c944b7ea8db35531b97847b6 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 21 Sep 2020 12:14:32 +0100 Subject: [PATCH 2/6] chore: remove duplicate make target License: MIT Signed-off-by: Oli Evans --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index d27296c24..4216ae31f 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,6 @@ build: sentinel-visor deps: git submodule update --init --recursive -.PHONY: sentinel-visor -sentinel-visor: extern/filecoin-ffi/.install-filcrypto - rm -f ./sentinel-visor - go build -o sentinel-visor . - # test starts dependencies and runs all tests .PHONY: test test: dockerup testfull dockerdown From cc146ffa07c1de7cefc1f30ae8a2864cc48ea1b9 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 21 Sep 2020 14:03:39 +0100 Subject: [PATCH 3/6] chore: fix dockerfile License: MIT Signed-off-by: Oli Evans --- .dockerignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index ad93c6be3..3d319ad7a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,6 @@ /.circleci /.github /extern/filecoin-ffi -/visor /Dockerfile* /docker-compose* -/sentinel-visor \ No newline at end of file +/sentinel-visor From 6a200226dbc03c20e043a78c9f9a7a7f0f58532c Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 21 Sep 2020 14:20:14 +0100 Subject: [PATCH 4/6] chore: update Dockerfile to use make deps License: MIT Signed-off-by: Oli Evans --- .dockerignore | 1 + Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 3d319ad7a..92ec26421 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ /.circleci /.github +/build/* /extern/filecoin-ffi /Dockerfile* /docker-compose* diff --git a/Dockerfile b/Dockerfile index c2e2a882d..0a83808f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev WORKDIR /go/src/github.com/filecoin-project/sentinel-visor COPY . /go/src/github.com/filecoin-project/sentinel-visor -RUN make build +RUN make deps && make build # Runner FROM buildpack-deps:buster-curl From b536573b6d490830881d31cc767aece11f72091a Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 21 Sep 2020 14:50:13 +0100 Subject: [PATCH 5/6] chore: use the best go License: MIT Signed-off-by: Oli Evans --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0a83808f0..90bed76c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Builder -FROM golang:1.14.9 as builder +FROM golang:1.15.2 as builder # Install deps for filecoin-project/filecoin-ffi RUN apt-get update From 246c10770479785951fbce404069cbfa7cead97a Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Mon, 21 Sep 2020 15:37:34 +0100 Subject: [PATCH 6/6] chore: trailing newline License: MIT Signed-off-by: Oli Evans --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 90bed76c2..c40afe1b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,4 @@ COPY --from=builder /go/src/github.com/filecoin-project/sentinel-visor/sentinel- COPY --from=builder /usr/lib/x86_64-linux-gnu/libOpenCL.so* /lib/ ENTRYPOINT ["/usr/bin/sentinel-visor"] -CMD ["--help"] \ No newline at end of file +CMD ["--help"]