From 772904c527700db9460e39d66c0386889addb6e5 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 14 Jul 2021 18:09:51 -0300 Subject: [PATCH 1/3] Install npm@7 in the builder image; alpine comes with npm@6 --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 526a90f..d4aa214 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:12.22.3-alpine AS builder +RUN npm i -g npm@7.19.1 WORKDIR /otterscan-build COPY ["package.json", "package-lock.json", "/otterscan-build/"] RUN npm install From 54bc06a7ad754d610899be6f2af1208b8f2bd1a0 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 14 Jul 2021 18:10:07 -0300 Subject: [PATCH 2/3] Updated build instructions --- docs/other-ways-to-run-otterscan.md | 6 +++--- package.json | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/other-ways-to-run-otterscan.md b/docs/other-ways-to-run-otterscan.md index 0ebd85c..a23c31e 100644 --- a/docs/other-ways-to-run-otterscan.md +++ b/docs/other-ways-to-run-otterscan.md @@ -16,7 +16,7 @@ Clone Otterscan repo and its submodules. Checkout the tag corresponding to your git clone --recurse-submodules git@github.com:wmitsuda/otterscan.git cd otterscan git checkout -docker build -t otterscan -f Dockerfile . +DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile . ``` This will run the entire build process inside a build container, merge the production build of the React app with the 4bytes and trustwallet assets into the same image format it is published in Docker Hub, but locally under the name `otterscan`. @@ -47,13 +47,13 @@ By default, it assumes your Erigon `rpcdaemon` processs is serving requests at ` Start serving 4bytes and trustwallet assets at `localhost:3001` using a dockerized nginx: ``` -npm run start-assets +npm run assets-start ``` To stop it, run: ``` -npm run stop-assets +npm run assets-stop ``` To run Otterscan development build: diff --git a/package.json b/package.json index 09b401f..76504bb 100644 --- a/package.json +++ b/package.json @@ -43,11 +43,11 @@ "build": "craco build", "test": "craco test", "eject": "react-scripts eject", - "start-assets": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets -v$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", - "stop-assets": "docker stop otterscan-assets", - "build-docker": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .", - "start-docker": "docker run --rm -p 5000:80 --name otterscan -d otterscan", - "stop-docker": "docker stop otterscan" + "assets-start": "docker run --rm -p 3001:80 --name otterscan-assets -d -v$(pwd)/4bytes/signatures:/usr/share/nginx/html/signatures/ -v$(pwd)/trustwallet/blockchains/ethereum/assets:/usr/share/nginx/html/assets -v$(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf nginx:1.21.1-alpine", + "assets-stop": "docker stop otterscan-assets", + "docker-build": "DOCKER_BUILDKIT=1 docker build -t otterscan -f Dockerfile .", + "docker-start": "docker run --rm -p 5000:80 --name otterscan -d otterscan", + "docker-stop": "docker stop otterscan" }, "eslintConfig": { "extends": [ From 3f95d0112633ea22c830e1cede043b09cc424052 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 14 Jul 2021 18:17:38 -0300 Subject: [PATCH 3/3] Add aggressive caching for /static directory --- nginx.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nginx.conf b/nginx.conf index 029fb69..55189ba 100644 --- a/nginx.conf +++ b/nginx.conf @@ -4,6 +4,11 @@ server { #access_log /var/log/nginx/host.access.log main; + location /static { + root /usr/share/nginx/html; + expires max; + } + location /signatures { root /usr/share/nginx/html; expires 30d;