diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 94921d904..c0231482b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,23 +24,22 @@ jobs: TARGET_HOST: ${{ secrets.STAGING_HOST }} run: | echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.beta-addr.dm3.eth" >> ./.env.react - echo "REACT_APP_BACKEND=http://${{ secrets.STAGING_HOST }}" >> ./.env.react + echo "REACT_APP_BACKEND=http://${{ secrets.STAGING_HOST }}/api" >> ./.env.react echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./.env.react - echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.STAGING_HOST }}" >> ./.env.react + echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.STAGING_HOST }}/api" >> ./.env.react echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.REACT_APP_ETHEREUM_PROVIDER }}" >> ./.env.react - echo "REACT_APP_PROFILE_BASE_URL=http://dm3-beta2-resolver.herokuapp.com" >> ./.env.react - echo "REACT_APP_RESOLVER_BACKEND=http://dm3-beta2-resolver.herokuapp.com" >> ./.env.react + echo "REACT_APP_PROFILE_BASE_URL=http://${{ secrets.STAGING_HOST }}/api" >> ./.env.react + echo "REACT_APP_RESOLVER_BACKEND=http://${{ secrets.STAGING_HOST }}/resolver-handler" >> ./.env.react echo "REACT_APP_USER_ENS_SUBDOMAIN=.beta-user.dm3.eth" >> ./.env.react echo "REACT_APP_WALLET_CONNECT_PROJECT_ID=${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}" >> ./.env.react echo "RESOLVER_ADDR=0x45F7Ed7d05c563D408898A80d9C705CC3328D2EF" >> ./.env - echo "WEB_PORT=80" >> ./.env echo "SIGNING_PUBLIC_KEY=${{ secrets.SIGNING_PUBLIC_KEY }}" >> ./.env echo "SIGNING_PRIVATE_KEY=${{ secrets.SIGNING_PRIVATE_KEY }}" >> ./.env echo "SIGNER_PRIVATE_KEY=${{ secrets.SIGNER_PRIVATE_KEY }}" >> ./.env echo "SPAM_PROTECTION=${{ secrets.SPAM_PROTECTION }}" >> ./.env echo "ENCRYPTION_PUBLIC_KEY=${{ secrets.ENCRYPTION_PUBLIC_KEY }}" >> ./.env echo "ENCRYPTION_PRIVATE_KEY=${{ secrets.ENCRYPTION_PRIVATE_KEY }}" >> ./.env - echo "RPC=${{ secrets.RPC }}" >> ./.env + echo "RPC=${{ secrets.STAGING_RPC }}" >> ./.env envsubst '${SSL_CERTIFICATE_BASE_LOC} ${TLS_CERTIFICATE_LOCATION} ${TARGET_HOST}' < ./docker/nginx.conf > ./nginx.conf - name: Build docker image run: | @@ -53,10 +52,11 @@ jobs: rsync -avz -e 'ssh -i ./ssh-key' ./dm3-backend.tar app@${{ secrets.STAGING_HOST }}:/home/app/dm3 rsync -avz -e 'ssh -i ./ssh-key' ./nginx.conf app@${{ secrets.STAGING_HOST }}:/home/app/dm3 rsync -avz -e 'ssh -i ./ssh-key' ./docker/docker-compose.yml app@${{ secrets.STAGING_HOST }}:/home/app/dm3 - - name: Load image + - name: Load docker image run: | ssh -i ./ssh-key app@${{ secrets.STAGING_HOST }} "\ - cd dm3 && docker load -i dm3-backend.tar" + cd dm3 && docker load -i dm3-backend.tar; \ + rm dm3-backend.tar" - name: Start run: | ssh -i ./ssh-key app@${{ secrets.STAGING_HOST }} "\ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0a26c66a1..7155b0506 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,15 +1,18 @@ version: "3.1" services: - # nginx: - # container_name: nginx - # image: nginx:latest - # restart: always - # volumes: - # - ./nginx.conf:/etc/nginx/nginx.conf - # ports: - # - "80:80" - # - "443:443" + nginx: + container_name: nginx + image: nginx:latest + restart: always + depends_on: + - offchain-resolver + - web + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + ports: + - "80:80" + - "443:443" backend: image: dm3-backend @@ -23,6 +26,8 @@ services: ENCRYPTION_PUBLIC_KEY: ${ENCRYPTION_PUBLIC_KEY} ENCRYPTION_PRIVATE_KEY: ${ENCRYPTION_PUBLIC_KEY} RPC: ${RPC} + ports: + - '8081:8081' db: image: redis @@ -63,7 +68,7 @@ services: REACT_APP_WALLET_CONNECT_PROJECT_ID: ${REACT_APP_WALLET_CONNECT_PROJECT_ID} RESOLVER_ADDR: ${RESOLVER_ADDR} ports: - - '${WEB_PORT}:8080' + - '8080:8080' ccip-resolver: image: dm3org/ccip-resolver:v0.2.2 @@ -75,7 +80,7 @@ services: LOG_LEVEL: debug CONFIG: | { - "0x5e0F81D5ca51D309B3A046FAeea70C4C70Df8079": { + "0x4283441191a27513c2160c1e7BC1aa02Ab84D900": { "type": "signing", "handlerUrl": "http://offchain-resolver:8081" } diff --git a/docker/nginx.conf b/docker/nginx.conf index d8e980104..a5c0da79e 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -4,7 +4,8 @@ events { http { keepalive_timeout 65; - + limit_req_zone $binary_remote_addr zone=standardlimit:10m rate=3r/s; + limit_req_zone $binary_remote_addr zone=legacylimit:10m rate=2r/s; server { listen 80; @@ -22,6 +23,43 @@ http { } + location /resolver { + rewrite ^/resolver(.*)$ $1 break; + limit_req zone=standardlimit burst=50; + proxy_pass http://ccip-resolver:8181; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_redirect off; + } + + location /resolver-handler { + rewrite ^/resolver(.*)$ $1 break; + limit_req zone=standardlimit burst=50; + proxy_pass http://offchain-resolver:8082; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_redirect off; + } + + location /api { + rewrite ^/api(.*)$ $1 break; + limit_req zone=standardlimit burst=50; + proxy_pass http://backend:8081; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_redirect off; + } + + } diff --git a/packages/lib/offchainResolver-api/package.json b/packages/lib/offchainResolver-api/package.json index 4c373ed40..4eb93975f 100644 --- a/packages/lib/offchainResolver-api/package.json +++ b/packages/lib/offchainResolver-api/package.json @@ -11,7 +11,7 @@ } }, "dependencies": { - "axios": "^1.3.4", + "axios": "^1.5.0", "dm3-lib-profile": "^0.2.0", "ethers": "5.7.2" }, diff --git a/packages/lib/offchainResolver-api/src/index.ts b/packages/lib/offchainResolver-api/src/index.ts index 6ac6cc938..8c68ccfe8 100644 --- a/packages/lib/offchainResolver-api/src/index.ts +++ b/packages/lib/offchainResolver-api/src/index.ts @@ -22,8 +22,8 @@ export async function claimSubdomain( name, signature: await wallet.signMessage('alias: ' + alias), }; - - const { status } = await axios.post(url, data); + const instance = axios.create(); + const { status } = await instance.post(url, data); return status === 200; } @@ -44,8 +44,8 @@ export async function removeAlias( name: alias, signature: await wallet.signMessage('remove: ' + alias), }; - - const { status } = await axios.post(url, data); + const instance = axios.create(); + const { status } = await instance.post(url, data); return status === 200; } @@ -65,8 +65,8 @@ export async function claimAddress( signedUserProfile, address, }; - - const { status } = await axios.post(url, data); + const instance = axios.create(); + const { status } = await instance.post(url, data); return status === 200; } @@ -81,7 +81,8 @@ export async function getNameForAddress( ): Promise { const url = `${offchainResolverUrl}/name/${formatAddress(address)}`; try { - const { data } = await axios.get(url); + const instance = axios.create(); + const { data } = await instance.get(url); return data.name; } catch (e) { return; diff --git a/packages/lib/profile/package.json b/packages/lib/profile/package.json index 8ce9fcabe..8e6d4b834 100644 --- a/packages/lib/profile/package.json +++ b/packages/lib/profile/package.json @@ -46,6 +46,6 @@ "test": "jest --coverage --transformIgnorePatterns 'node_modules/(?!(dm3-lib-\\w*)/)'" }, "files": [ - "dist" + "dist" ] } diff --git a/packages/messenger-widget/src/views/Home/Home.tsx b/packages/messenger-widget/src/views/Home/Home.tsx index acfef22cc..b1cb61951 100644 --- a/packages/messenger-widget/src/views/Home/Home.tsx +++ b/packages/messenger-widget/src/views/Home/Home.tsx @@ -9,7 +9,7 @@ import { RainbowKitProvider, } from '@rainbow-me/rainbowkit'; import { configureChains, createConfig, WagmiConfig } from 'wagmi'; -import { mainnet } from 'wagmi/chains'; +import { mainnet, goerli } from 'wagmi/chains'; import { metaMaskWallet, rainbowWallet, @@ -23,7 +23,7 @@ import { ConfigureProfile } from '../../components/ConfigureProfile/ConfigurePro export function Home(props: Dm3Props) { const { chains, publicClient } = configureChains( - [mainnet], + [goerli], [ jsonRpcProvider({ rpc: () => ({ diff --git a/yarn.lock b/yarn.lock index 7230635c5..3d2bc3a40 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7060,6 +7060,17 @@ __metadata: languageName: node linkType: hard +"axios@npm:^1.5.0": + version: 1.5.0 + resolution: "axios@npm:1.5.0" + dependencies: + follow-redirects: ^1.15.0 + form-data: ^4.0.0 + proxy-from-env: ^1.1.0 + checksum: e7405a5dbbea97760d0e6cd58fecba311b0401ddb4a8efbc4108f5537da9b3f278bde566deb777935a960beec4fa18e7b8353881f2f465e4f2c0e949fead35be + languageName: node + linkType: hard + "axobject-query@npm:^3.1.1": version: 3.2.1 resolution: "axobject-query@npm:3.2.1" @@ -10420,7 +10431,7 @@ __metadata: "@types/node": ^16.7.13 "@types/uuid": ^8.3.4 "@types/whatwg-encoding": ^2.0.0 - axios: ^1.3.4 + axios: ^1.5.0 axios-mock-adapter: ^1.21.2 dm3-lib-profile: ^0.2.0 ethers: 5.7.2