diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3918b1e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM golang:1.20-alpine as builder + +RUN apk --no-cache add g++ gcc make cmake git nano libcurl python3 python3-dev \ + curl bash curl-dev linux-headers sqlite-dev sed + +WORKDIR /root + +# ARG UPSTREAM_VER=feature/docker-version +# ADD https://api.github.com/repos/TrueBlocks/trueblocks-core/git/refs/heads/$UPSTREAM_VER version.json + +# UPDATE_VERSION_HERE +ARG UPSTREAM_VER=v0.70.0-beta +# ARG UPSTREAM_VER=develop +RUN git clone -b "${UPSTREAM_VER}" --single-branch --progress --depth 1 \ + https://github.com/TrueBlocks/trueblocks-core.git && \ + cd trueblocks-core && \ + cat src/libs/CMakeLists.txt | grep -v "test-libs" >x && \ + cat x >src/libs/CMakeLists.txt && \ + cat src/CMakeLists.txt | grep -v "examples" | grep -v dev_tools >x && \ + cat x >src/CMakeLists.txt && \ + rm -f x && \ + mkdir -p build && \ + cd build && \ + cmake ../src && \ + make -j 5 + +FROM alpine:latest + +RUN apk --no-cache add gzip libstdc++ libgcc libcurl python3 python3-dev procps bash curl nano findutils + +COPY --from=builder /root/trueblocks-core/bin /usr/local/bin +COPY --from=builder /root/.local/bin/chifra /root/.local/bin/chifra +COPY --from=builder /root/.local/share/trueblocks /root/.local/share/trueblocks + +ARG SERVE_PORT=8080 +EXPOSE ${SERVE_PORT} + +CMD ["chifra", "daemon", "--api", "on", "--scrape", "index"] diff --git a/configuration/docker/Dockerfile b/configuration/docker/Dockerfile deleted file mode 100644 index 14a3416..0000000 --- a/configuration/docker/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -# Latest golang as builder -FROM golang:1.18-alpine as builder - -# Install build depenedencies -RUN apk --no-cache add git nano - -# Set workdir -WORKDIR /root - -# Try to get upstream version (default v0.44.0-beta) -ARG UPSTREAM_VER=v0.44.0-beta - -# Clone and make TrueBlocks Core -# make -j 5 is a fairly safe number -RUN git clone -b "${UPSTREAM_VER}" --single-branch --progress --depth 1 \ - https://github.com/TrueBlocks/trueblocks-dappnode.git && \ - cd trueblocks-dappnode/configuration && go build -o server - -# Switch to alpine container -FROM alpine:latest - -# Install binary dependencies and nice to haves -RUN apk --no-cache add nano - -# Copy files from builder -COPY --from=builder /root/trueblocks-dappnode/configuration/server /app/server -COPY --from=builder /root/trueblocks-dappnode/configuration/static /app/static - -EXPOSE 80 - -# Run entrypoint -ENTRYPOINT /app/server --static /app/static diff --git a/configuration/go.mod b/configuration/go.mod deleted file mode 100644 index 5f86150..0000000 --- a/configuration/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/TrueBlocks/trueblocks-dappnode/configuration - -go 1.18 diff --git a/configuration/main.go b/configuration/main.go deleted file mode 100644 index b9ccfea..0000000 --- a/configuration/main.go +++ /dev/null @@ -1,243 +0,0 @@ -package main - -import ( - "encoding/json" - "flag" - "fmt" - "io/ioutil" - "log" - "net/http" - "os" - "path" - "strconv" - "strings" -) - -type ConfigurationItem struct { - Name string - Rpc string - ChainId string - Symbol string - IpfsGateway string - LocalExplorer string - RemoteExplorer string - ScraperArgs string - ScraperFile string -} - -type GlobalConfiguration struct { - RunScraper bool - InitBlooms bool - InitIndex bool - MonitorArgs string - MonitorFile string - EtherscanKey string - DefaultGateway string -} - -type ConfigurationPost struct { - Global GlobalConfiguration - Chains []ConfigurationItem -} - -func EnvsFromConfiguration(item ConfigurationItem) string { - var b strings.Builder - - prefix := fmt.Sprintf("export TB_CHAINS_%s_", strings.ToUpper(item.Name)) - b.WriteString(prefix + "CHAINID=" + item.ChainId + "\n") - b.WriteString(prefix + "RPCPROVIDER=" + item.Rpc + "\n") - b.WriteString(prefix + "SYMBOL=" + item.Symbol + "\n") - - if item.IpfsGateway != "" { - b.WriteString(prefix + "IPFSGATEWAY=" + item.IpfsGateway + "\n") - } - if item.LocalExplorer != "" { - b.WriteString(prefix + "LOCALEXPLORER=" + item.LocalExplorer + "\n") - } - if item.RemoteExplorer != "" { - b.WriteString(prefix + "REMOTEEXPLORER=" + item.RemoteExplorer + "\n") - } - if item.ScraperArgs != "" { - b.WriteString(fmt.Sprintf("export SCRAPER_%s_ARGS=%s\n", strings.ToUpper(item.Name), normalizeUserInput(item.ScraperArgs))) - } - if item.ScraperFile != "" { - b.WriteString(fmt.Sprintf("export SCRAPER_%s_FILE=%s\n", strings.ToUpper(item.Name), normalizeUserInput(item.ScraperFile))) - } - - return b.String() -} - -func WriteEnvFile(path string, contents string) (err error) { - file, err := os.Create(path) - defer func() { - err := file.Close() - if err != nil { - panic(err) - } - }() - if err != nil { - return - } - - _, err = file.WriteString(contents) - if err != nil { - return - } - - return nil -} - -func normalizeUserInput(content string) string { - return strconv.Quote(content) -} - -func SaveConfiguration(path string, config ConfigurationPost) (err error) { - lines := []string{ - "#!/bin/bash", - fmt.Sprint("export RUN_SCRAPER=", config.Global.RunScraper), - fmt.Sprint("export BOOTSTRAP_BLOOM_FILTERS=", config.Global.InitBlooms), - fmt.Sprint("export BOOTSTRAP_FULL_INDEX=", config.Global.InitIndex), - fmt.Sprint("export TB_KEYS_ETHERSCAN_APIKEY=", normalizeUserInput(config.Global.EtherscanKey)), - fmt.Sprint("export TB_SETTINGS_DEFAULTGATEWAY=", config.Global.DefaultGateway), - } - if config.Global.MonitorArgs != "" { - lines = append(lines, fmt.Sprint("export MONITORS_ARGS=", normalizeUserInput(config.Global.MonitorArgs))) - } - if config.Global.MonitorFile != "" { - lines = append(lines, fmt.Sprint("export MONITORS_FILE=", normalizeUserInput(config.Global.MonitorFile))) - } - - for _, item := range config.Chains { - lines = append(lines, EnvsFromConfiguration(item)) - } - err = WriteEnvFile(path, strings.Join(lines, "\n")) - return err -} - -func SaveEntrypointScript(path string, config ConfigurationPost) (err error) { - scraperOpts := "off" - if (config.Global.RunScraper && config.Global.InitBlooms) { - scraperOpts = "blooms" - } - if (config.Global.RunScraper && config.Global.InitIndex) { - scraperOpts = "full-index" - } - cmdOpts := []string{ - "chifra daemon", - "--api on", - "--scrape", - scraperOpts, - "--monitor", - } - - script := []string{ - "#!/bin/bash", - "", - strings.Join(cmdOpts, " "), - "", - } - - err = WriteEnvFile(path, strings.Join(script, "\n")) - if err != nil { - return err - } - err = os.Chmod(path, 0700) - return err -} - -func SaveJson(path string, config ConfigurationPost) (err error) { - contents, err := json.MarshalIndent(config, "", " ") - if err != nil { - return - } - - file, err := os.Create(path) - if err != nil { - return - } - - file.Write(contents) - return nil -} - -func ReadJson(path string) (contents []byte, err error) { - contents, err = ioutil.ReadFile(path) - if err != nil { - return - } - - return -} - -func makeConfigurationHandler(outputDir string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost && r.Method != http.MethodGet { - http.Error(w, "unsupported method", http.StatusMethodNotAllowed) - return - } - - if r.Method == http.MethodPost { - log.Println("POST /configuration") - - p := ConfigurationPost{} - - err := json.NewDecoder(r.Body).Decode(&p) - if err != nil { - log.Println("error", err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - err = SaveConfiguration(path.Join(outputDir, "configuration.sh"), p) - if err != nil { - http.Error(w, fmt.Sprintf("Could not save configuration file: %s", err), http.StatusInternalServerError) - return - } - err = SaveEntrypointScript(path.Join(outputDir, "entrypoint.sh"), p) - if err != nil { - http.Error(w, fmt.Sprintf("Could not update entrypoint script: %s", err), http.StatusInternalServerError) - return - } - err = SaveJson(path.Join(outputDir, "configuration.json"), p) - if err != nil { - http.Error(w, fmt.Sprintf("Could not save JSON configuration file: %s", err), http.StatusInternalServerError) - return - } - } - - if r.Method == http.MethodGet { - log.Println("GET /configuration") - - data, err := ReadJson(path.Join(outputDir, "configuration.json")) - if err != nil { - http.Error(w, fmt.Sprintf("Could not read JSON configuration file: %s", err), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - w.Write(data) - } - } -} - -func main() { - var outputPath string - var port string - var staticDir string - - flag.StringVar(&outputPath, "dir", "/output/", "Path to output directory") - flag.StringVar(&port, "port", "80", "Port to listen on") - flag.StringVar(&staticDir, "static", "./static", "Directory to serve static files from") - flag.Parse() - log.Println("Will save output to", outputPath) - - http.HandleFunc("/configuration", makeConfigurationHandler(outputPath)) - - fs := http.FileServer(http.Dir(staticDir)) - http.Handle("/", fs) - - log.Print("Listening on ", port) - err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil) - if err != nil { - log.Fatal(err) - } -} diff --git a/configuration/static/index.html b/configuration/static/index.html deleted file mode 100644 index b0cd429..0000000 --- a/configuration/static/index.html +++ /dev/null @@ -1,712 +0,0 @@ - - - - - Configure TrueBlocks - - - -
-
-
- TrueBlocks logo -

Configure TrueBlocks

-
-
-

- This tool makes it easier to configure TrueBlocks Core DAppNode package. You can add or remove chains and change monitor watch options. -

-

- Remember to restart our DAppNode package after changing the configuration -

-

- If you need help, let us know on Discord or create new issue. -

-
-
-
- -
-
-
- -
-
- -
-
-
- -
- -

Do you want to remove this chain?

-

- This action cannot be undone. -

-
- - -
-
- - - - - - - - - - - - - - -
-

Global settings

- -
-
- - Run scraper - -
- - -
-

- Scan the chain and update the TrueBlocks index of appearances. This requires an endpoint that supports trace_* methods as your RPC Provider (not geth). -

-
-
- - Download bloom filters: - -
- - -
-

- Download mainnet bloom filters on startup? Otherwise they must be generated locally. This is recommended (~3GB). -

-
- - - -
- Advanced settings -
-
- - Download full index: - -
- - -
-

- Download the entire mainnet index on startup? This is NOT recommended as it takes up considerable space (~80GB). -

-
- - -
-
-
- - - -

Chains

-
- -
-
- -
- - - - - \ No newline at end of file diff --git a/configuration/static/logo.png b/configuration/static/logo.png deleted file mode 100644 index b33aca1..0000000 Binary files a/configuration/static/logo.png and /dev/null differ diff --git a/dappnode_package.json b/dappnode_package.json index e15f4e1..7dd0d9c 100644 --- a/dappnode_package.json +++ b/dappnode_package.json @@ -1,37 +1,13 @@ { "name": "trueblocks.public.dappnode.eth", - "version": "0.50.0", - "shortDescription": "Lightweight indexing for any EVM-based blockchain", - "description": "TrueBlocks is a collection of libraries, tools, and applications that improve access to the Ethereum data while remaining fully local. To configure, go to configure.trueblocks.public.dappnode", + "version": "0.0.7", + "upstreamVersion": "0.70.0-beta", + "description": "TrueBlocks packaged for DAppNode", "type": "service", - "mainService": "core", - "author": "TrueBlocks, LLC. (https://trueblocks.io)", - "contributors": [], - "categories": ["Developer tools", "Blockchain", "Communications"], - "keywords": ["trueblocks", "index", "indexing", "ipfs", "data"], - "backup": [ - { - "name": "trueblocks_data", - "path": "/root/.local/share/trueblocks", - "service": "core" - } - ], - "exposable": [], - "repository": { - "type": "git", - "url": "https://github.com/TrueBlocks/trueblocks-dappnode" - }, - "bugs": { - "url": "https://github.com/TrueBlocks/trueblocks-dappnode/issues" - }, - "warnings": { - "onInstall": "After installing TrueBlocks, please go to Packages -> TrueBlocks and click Settings link to configure this package." - }, + "author": "geleeroyale", + "categories": ["Developer tools"], "links": { - "settings": "http://configure.trueblocks.public.dappnode", - "api": "http://trueblocks.public.dappnode:8080", - "readme": "https://github.com/TrueBlocks/trueblocks-dappnode", "homepage": "https://trueblocks.io" }, - "license": "GLP-3.0" + "license": "GPL-3.0" } diff --git a/docker-compose.yml b/docker-compose.yml index fa457d6..83a1ee8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,29 +1,19 @@ version: "3.5" services: - core: - image: "trueblocks/core:v0.50.0-beta" - entrypoint: | - bash -c "\ - while [ ! -f /configuration/entrypoint.sh ] \ - do \ - echo No configuration found. Please use TrueBlocks Configuration Tool first. \ - echo If you are using DAppNode, click Info tab above, then Settings link. \ - echo Will try to re-read the configuration in a few seconds \ - sleep 5 \ - done \ - . /configuration/configuration.sh && \ - sh /configuration/entrypoint.sh" - ports: - - "8080:8080/tcp" - restart: unless-stopped - volumes: - - "configuration:/configuration" - - "trueblocks:/root/.local/share/trueblocks" - configure: - image: "trueblocks/config:v0.44.0-beta" + trueblocks.public.dappnode.eth: + build: . + image: "trueblocks.public.dappnode.eth:0.0.7" + environment: + TB_SETTINGS_DEFAULTCHAIN: mainnet + TB_CHAINS_MAINNET_RPCPROVIDER: "http://erigon.dappnode:8545" + TB_SETTINGS_CACHEPATH: /cache + TB_SETTINGS_INDEXPATH: /unchained restart: unless-stopped + ports: + - "8085:8080" volumes: - - "configuration:/output" + - "cache:/cache" + - "unchained:/unchained" volumes: - configuration: {} - trueblocks: {} + cache: {} + unchained: {} diff --git a/releases.json b/releases.json index aa7fda7..bc9934c 100644 --- a/releases.json +++ b/releases.json @@ -1,20 +1,32 @@ { - "0.37.0": { - "hash": "/ipfs/Qmc1TBFy7neU151bjQWmNygwowScwk4yFXXMuukjFAeEFJ", + "0.0.1": { + "hash": "/ipfs/QmcayDk4G4i3WEVErBUeC5sXzuPaAz9Jxk4aEo34TZWxSg", "uploadedTo": { - "dappnode": "Thu, 07 Jul 2022 11:46:29 GMT" + "http://172.33.1.5:5001": "Thu, 15 Jun 2023 12:10:27 GMT" } }, - "0.45.0": { - "hash": "/ipfs/QmZZfEGDKu5tNyERx15pnABvc6wTBCqWetuTV8fzRYosUS", + "0.1.0": { + "hash": "/ipfs/QmNcghRgQHxY8ytwhJnKTeU5ohkb4N7fN1qZfYJkPJQcmx", "uploadedTo": { - "dappnode": "Thu, 22 Dec 2022 12:00:59 GMT" + "http://172.33.1.5:5001": "Thu, 15 Jun 2023 13:52:52 GMT" } }, - "0.50.0": { - "hash": "/ipfs/QmUk3f97DK2AVC4HRtnnHJjFB24C5ywP748p9FwGossTou", + "0.1.1": { + "hash": "/ipfs/Qme1zwZQ2PdpG6MqiaZWAocmnPhCzCVzV1Kxow8eatMYW7", "uploadedTo": { - "dappnode": "Fri, 23 Dec 2022 07:19:08 GMT" + "http://172.33.1.5:5001": "Thu, 15 Jun 2023 14:04:41 GMT" + } + }, + "0.1.2": { + "hash": "/ipfs/Qma4AuNe2vvSHqkJLxYThVZRn6oFLmXEZJ4XGruy4Tq2LP", + "uploadedTo": { + "http://172.33.1.5:5001": "Thu, 15 Jun 2023 14:25:53 GMT" + } + }, + "0.0.6": { + "hash": "/ipfs/QmeXiHfhar45Y9M494Ykc3Tp8jYzer2gxjzzDoRNZa5sP1", + "uploadedTo": { + "http://172.33.1.5:5001": "Thu, 15 Jun 2023 15:09:53 GMT" } } }