Skip to content

Commit

Permalink
build: staging conf
Browse files Browse the repository at this point in the history
  • Loading branch information
hai-ko committed Sep 4, 2023
1 parent 8c819cb commit d4591d6
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 32 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }} "\
Expand Down
27 changes: 16 additions & 11 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -75,7 +80,7 @@ services:
LOG_LEVEL: debug
CONFIG: |
{
"0x5e0F81D5ca51D309B3A046FAeea70C4C70Df8079": {
"0x4283441191a27513c2160c1e7BC1aa02Ab84D900": {
"type": "signing",
"handlerUrl": "http://offchain-resolver:8081"
}
Expand Down
40 changes: 39 additions & 1 deletion docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}


}


Expand Down
2 changes: 1 addition & 1 deletion packages/lib/offchainResolver-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"dependencies": {
"axios": "^1.3.4",
"axios": "^1.5.0",
"dm3-lib-profile": "^0.2.0",
"ethers": "5.7.2"
},
Expand Down
15 changes: 8 additions & 7 deletions packages/lib/offchainResolver-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -81,7 +81,8 @@ export async function getNameForAddress(
): Promise<string | undefined> {
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;
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/profile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"test": "jest --coverage --transformIgnorePatterns 'node_modules/(?!(dm3-lib-\\w*)/)'"
},
"files": [
"dist"
"dist"
]
}
4 changes: 2 additions & 2 deletions packages/messenger-widget/src/views/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,7 +23,7 @@ import { ConfigureProfile } from '../../components/ConfigureProfile/ConfigurePro

export function Home(props: Dm3Props) {
const { chains, publicClient } = configureChains(
[mainnet],
[goerli],
[
jsonRpcProvider({
rpc: () => ({
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d4591d6

Please sign in to comment.