From 2c7fb40452f0b15353c32e275090811971ad86a6 Mon Sep 17 00:00:00 2001 From: fearlessfe <505380967@qq.com> Date: Mon, 19 Aug 2024 22:04:54 +0800 Subject: [PATCH] feat: add deploy doc for super proof frontend --- .../super-proof-docs/deployment/use_docker.md | 194 +++++++++++++----- 1 file changed, 139 insertions(+), 55 deletions(-) diff --git a/docs/super-proof-docs/deployment/use_docker.md b/docs/super-proof-docs/deployment/use_docker.md index adc6b0f..b616e3e 100644 --- a/docs/super-proof-docs/deployment/use_docker.md +++ b/docs/super-proof-docs/deployment/use_docker.md @@ -18,7 +18,7 @@ mv .env.template .evn ``` #log_format you can use console or json -LOG_FORMAT=console +LOG_FORMAT=console # config your mysql data source MYSQL_DATA_SOURCE= @@ -80,30 +80,33 @@ You should get a result, similar to : ```json { - "results": [{ - "name": "Default Search API Key", - "description": "Use it to search from the frontend", - "key": "d09536ef1e2742b4792c607465dc169f659f1b2dcb0107bfdce2542b602ed534", - "uid": "675ff658-9e73-460c-a3be-c6fcee624edf", - "actions": ["search"], - "indexes": ["*"], - "expiresAt": null, - "createdAt": "2024-08-06T08:47:38.225365511Z", - "updatedAt": "2024-08-06T08:47:38.225365511Z" - }, { - "name": "Default Admin API Key", - "description": "Use it for anything that is not a search operation. Caution! Do not expose it on a public frontend", - "key": "abc40e8457b32aa86d20ab0db0b42a86298b253209c4c31d9936b378e686d132", - "uid": "db1499f6-59a1-42c7-a13a-e18e191f456c", - "actions": ["*"], - "indexes": ["*"], - "expiresAt": null, - "createdAt": "2024-08-06T08:47:38.225052792Z", - "updatedAt": "2024-08-06T08:47:38.225052792Z" - }], - "offset": 0, - "limit": 20, - "total": 2 + "results": [ + { + "name": "Default Search API Key", + "description": "Use it to search from the frontend", + "key": "d09536ef1e2742b4792c607465dc169f659f1b2dcb0107bfdce2542b602ed534", + "uid": "675ff658-9e73-460c-a3be-c6fcee624edf", + "actions": ["search"], + "indexes": ["*"], + "expiresAt": null, + "createdAt": "2024-08-06T08:47:38.225365511Z", + "updatedAt": "2024-08-06T08:47:38.225365511Z" + }, + { + "name": "Default Admin API Key", + "description": "Use it for anything that is not a search operation. Caution! Do not expose it on a public frontend", + "key": "abc40e8457b32aa86d20ab0db0b42a86298b253209c4c31d9936b378e686d132", + "uid": "db1499f6-59a1-42c7-a13a-e18e191f456c", + "actions": ["*"], + "indexes": ["*"], + "expiresAt": null, + "createdAt": "2024-08-06T08:47:38.225052792Z", + "updatedAt": "2024-08-06T08:47:38.225052792Z" + } + ], + "offset": 0, + "limit": 20, + "total": 2 } ``` @@ -111,7 +114,7 @@ And, use `Default Admin API Key`, `key` to update config.yml ``` meilisearch: - api_url: http://localhost:7701 + api_url: http://localhost:7701 api_key: abc40e8457b32aa86d20ab0db0b42a86298b253209c4c31d9936b378e686d132 ``` @@ -134,36 +137,117 @@ You should get a result, similar to : ```json { - "results": [ - { - "uid": "disputegame", - "createdAt": "2024-08-06T09:24:24.640693956Z", - "updatedAt": "2024-08-07T07:02:32.402360903Z", - "primaryKey": "id" - }, - { - "uid": "gameclaim", - "createdAt": "2024-08-06T09:24:24.670117944Z", - "updatedAt": "2024-08-07T07:02:28.94487306Z", - "primaryKey": "id" - }, - { - "uid": "gamecredit", - "createdAt": "2024-08-06T10:37:42.013472322Z", - "updatedAt": "2024-08-07T07:02:32.379350451Z", - "primaryKey": "id" - }, - { - "uid": "syncevents", - "createdAt": "2024-08-06T09:24:24.696318772Z", - "updatedAt": "2024-08-07T07:02:30.382386632Z", - "primaryKey": "id" - } - ], - "offset": 0, - "limit": 20, - "total": 4 + "results": [ + { + "uid": "disputegame", + "createdAt": "2024-08-06T09:24:24.640693956Z", + "updatedAt": "2024-08-07T07:02:32.402360903Z", + "primaryKey": "id" + }, + { + "uid": "gameclaim", + "createdAt": "2024-08-06T09:24:24.670117944Z", + "updatedAt": "2024-08-07T07:02:28.94487306Z", + "primaryKey": "id" + }, + { + "uid": "gamecredit", + "createdAt": "2024-08-06T10:37:42.013472322Z", + "updatedAt": "2024-08-07T07:02:32.379350451Z", + "primaryKey": "id" + }, + { + "uid": "syncevents", + "createdAt": "2024-08-06T09:24:24.696318772Z", + "updatedAt": "2024-08-07T07:02:30.382386632Z", + "primaryKey": "id" + } + ], + "offset": 0, + "limit": 20, + "total": 4 } ``` If you get information like this, it means our deploy it`s success. + +# Step 6. Start frontend + +pull the docker image + +```bash +docker pull ghcr.io/optimism-java/dispute-explorer-frontend:development +``` + +config the `nginx.conf`, below is a example, you should change the server part + +```bash +worker_processes 2; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + gzip on; + + server { + listen 80; + location / { + root html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + location ~ /index/ { + proxy_pass ${Sepolia meiliSearch}; # replace with Sepolia meiliSearch service url + proxy_set_header Host $host; + proxy_set_header X-Forward-For $remote_addr; + proxy_set_header X-Forward-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Authorization "Bearer $TOKEN"; # replace TOKEN with Sepolia meiliSearch token + } + location ~ /indexMain/ { + proxy_pass ${Mainnet meiliSearch}; # replace with Mainnet meiliSearch service url + proxy_set_header Host $host; + proxy_set_header X-Forward-For $remote_addr; + proxy_set_header X-Forward-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Authorization "Bearer $TOKEN"; # replace TOKEN with Mainnet meiliSearch token + } + location ~ /api/ { + proxy_pass ${Sepolia api server}; # replace with Sepolia api service url + proxy_set_header Host $host; + proxy_set_header X-Forward-For $remote_addr; + proxy_set_header X-Forward-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + location ~ /apiMain/ { + proxy_pass ${Mainnet api server}; # replace with Mainnet api service url + proxy_set_header Host $host; + proxy_set_header X-Forward-For $remote_addr; + proxy_set_header X-Forward-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + } +} +``` + +start the image, replace the `docker run -d -v` to the real `nginx.conf` path. Then you can visit `localhost:3000` + +```bash +docker run -d -v ${path to nginx.conf}:/etc/nginx/nginx.conf -p 3000:80 ghcr.io/optimism-java/dispute-explorer-frontend:development +```