Skip to content

Commit

Permalink
Merge branch 'billboard-devconnect' of https://github.com/corpus-io/dm3
Browse files Browse the repository at this point in the history
… into billboard-devconnect
  • Loading branch information
AlexNi245 committed Nov 3, 2023
2 parents 0896109 + 42db225 commit bd36c0d
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 19 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/deploy-billboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Staging billboard deploy
on: push

jobs:
messenger-demo-deploy:
runs-on: ubuntu-latest
# if: ${{ contains( github.ref, vars.STAGING_BRANCH) }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
registry-url: 'https://npm.pkg.github.com'
node-version: 18.0.0
cache: 'yarn'
- name: Declare some variables
shell: bash
run: |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> "$GITHUB_ENV"
echo "now=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Prepare SSH
run: |
mkdir ~/.ssh
echo "${{ secrets.STAGING_HOST_SSH_BILLBOARD }}" > ~/.ssh/known_hosts
echo "${{ secrets.DO_SSH_KEY }}" > ./ssh-key
chmod 600 ./ssh-key
- name: Create .env file
env:
TARGET_HOST: ${{ secrets.STAGING_HOST_BILLBOARD }}
run: |
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.beta-addr.dm3.eth" >> ./.env.react
echo "REACT_APP_BACKEND=http://${{ secrets.STAGING_HOST_BILLBOARD }}/api" >> ./.env.react
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./.env.react
echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.STAGING_HOST_BILLBOARD }}/api" >> ./.env.react
echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.REACT_APP_ETHEREUM_PROVIDER }}" >> ./.env.react
echo "REACT_APP_PROFILE_BASE_URL=http://${{ secrets.STAGING_HOST_BILLBOARD }}/api" >> ./.env.react
echo "REACT_APP_RESOLVER_BACKEND=http://${{ secrets.STAGING_HOST_BILLBOARD }}/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 "REACT_APP_COMMIT_HASH=${{ env.sha_short }}" >> ./.env.react
echo "REACT_APP_BRANCH=${{ env.branch }}" >> ./.env.react
echo "REACT_APP_BUILD_TIME=${{ env.now }}" >> ./.env.react
cat ./.env.react >> ./.env
echo "RESOLVER_ADDR=0xae6646c22D8eE6479eE0a39Bf63B9bD9e57bAD9d" >> ./.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.STAGING_RPC }}" >> ./.env
echo "BILLBOARD_PRIVATE_KEY=${{ secrets.BILLBOARD_PRIVATE_KEY}}" >> ./.env
echo "interceptor=${{ secrets.INTERCEPTOR}}" >> ./.env
envsubst '${SSL_CERTIFICATE_BASE_LOC} ${TLS_CERTIFICATE_LOCATION} ${TARGET_HOST}' < ./docker/nginx.conf > ./nginx.conf
cat ./.env
- name: Build docker image
run: |
cp ./.env.react packages/messenger-demo/.env
docker build --progress=plain -t dm3-backend:latest -f ./docker/Dockerfile .
docker save -o ./dm3-backend.tar dm3-backend:latest
- name: Sync files
run: |
rsync -avz -e 'ssh -i ./ssh-key' ./.env app@${{ secrets.STAGING_HOST_BILLBOARD }}:/home/app/dm3
rsync -avz -e 'ssh -i ./ssh-key' ./dm3-backend.tar app@${{ secrets.STAGING_HOST_BILLBOARD }}:/home/app/dm3
rsync -avz -e 'ssh -i ./ssh-key' ./nginx.conf app@${{ secrets.STAGING_HOST_BILLBOARD }}:/home/app/dm3
rsync -avz -e 'ssh -i ./ssh-key' ./docker/billboard/docker-compose.yml app@${{ secrets.STAGING_HOST_BILLBOARD }}:/home/app/dm3
- name: Prepare docker
run: |
ssh -i ./ssh-key app@${{ secrets.STAGING_HOST_BILLBOARD }} "\
cd dm3 && docker compose down && docker system prune -af"
ssh -i ./ssh-key root@${{ secrets.STAGING_HOST_BILLBOARD }} "\
systemctl restart docker.service"
- name: Load docker image
run: |
ssh -i ./ssh-key app@${{ secrets.STAGING_HOST_BILLBOARD }} "\
cd dm3 && docker load -i dm3-backend.tar; \
rm dm3-backend.tar || true"
- name: Firewall config
run: |
ssh -i ./ssh-key root@${{ secrets.STAGING_HOST_BILLBOARD }} "\
ufw allow from 172.18.0.1/16 proto tcp to ${{ secrets.STAGING_HOST_BILLBOARD }} port 80"
- name: Start
run: |
ssh -i ./ssh-key app@${{ secrets.STAGING_HOST_BILLBOARD }} "\
cd dm3 && docker compose --env-file .env up -d"
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push Workflow
name: Staging deploy
on: push

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push Workflow
name: Build and test
on: push

jobs:
Expand Down
100 changes: 100 additions & 0 deletions docker/billboard/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
version: "3.1"
services:

nginx:
container_name: nginx
image: nginx:latest
restart: always
depends_on:
- offchain-resolver
- billboard-client
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
- "443:443"

backend:
image: dm3-backend
command: yarn workspace dm3-backend start
depends_on:
- db
environment:
REDIS_URL: redis://db:6379
SIGNING_PUBLIC_KEY: ${SIGNING_PUBLIC_KEY}
SIGNING_PRIVATE_KEY: ${SIGNING_PRIVATE_KEY}
ENCRYPTION_PUBLIC_KEY: ${ENCRYPTION_PUBLIC_KEY}
ENCRYPTION_PRIVATE_KEY: ${ENCRYPTION_PRIVATE_KEY}
RPC: ${RPC}
PORT: 8081
LOG_LEVEL: 'debug'

billboard-client:
image: dm3-backend
command: yarn workspace dm3-billboard-client start
depends_on:
- db
- ccip-resolver
environment:
PORT: 8082
time: 0
privateKey: ${BILLBOARD_PRIVATE_KEY}
ensNames: '["billboard1.eth"]'
mediators: '[]'
REDIS_URL: redis://db:6379
RPC: ${RPC}
LOG_LEVEL: 'debug'

db:
image: redis
restart: always

offchain-resolver-db:
image: postgres
restart: always
container_name: offchain_resolver_db
environment:
POSTGRES_PASSWORD: example

offchain-resolver:
image: dm3-backend
command: yarn workspace dm3-offchain-resolver start
depends_on:
- offchain-resolver-db
environment:
DATABASE_URL: postgresql://postgres:example@offchain-resolver-db:5432
PORT: 8082
LOG_LEVEL: 'debug'

# web:
# image: dm3-backend
# command: yarn workspace messenger-demo start
# environment:
# REACT_APP_ADDR_ENS_SUBDOMAIN: ${REACT_APP_ADDR_ENS_SUBDOMAIN}
# REACT_APP_BACKEND: ${REACT_APP_BACKEND}
# REACT_APP_DEFAULT_DELIVERY_SERVICE: ${REACT_APP_DEFAULT_DELIVERY_SERVICE}
# REACT_APP_DEFAULT_SERVICE: ${REACT_APP_DEFAULT_SERVICE}
# REACT_APP_ETHEREUM_PROVIDER: ${REACT_APP_ETHEREUM_PROVIDER}
# REACT_APP_PROFILE_BASE_URL: ${REACT_APP_PROFILE_BASE_URL}
# REACT_APP_RESOLVER_BACKEND: ${REACT_APP_RESOLVER_BACKEND}
# REACT_APP_USER_ENS_SUBDOMAIN: ${REACT_APP_USER_ENS_SUBDOMAIN}
# REACT_APP_WALLET_CONNECT_PROJECT_ID: ${REACT_APP_WALLET_CONNECT_PROJECT_ID}
# RESOLVER_ADDR: ${RESOLVER_ADDR}

ccip-resolver:
image: dm3org/ccip-resolver:v0.2.7
restart: always
depends_on:
- offchain-resolver
environment:
SIGNER_PRIVATE_KEY: ${SIGNER_PRIVATE_KEY}
LOG_LEVEL: debug
CONFIG: |
{
"0xae6646c22d8ee6479ee0a39bf63b9bd9e57bad9d": {
"type": "signing",
"handlerUrl": "http://offchain-resolver:8082"
}
}
PORT: 8181

18 changes: 9 additions & 9 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ http {
listen 80;
server_name ${TARGET_HOST};

location / {
limit_req zone=standardlimit burst=50;
proxy_pass http://web:8080;
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;
# location / {
# limit_req zone=standardlimit burst=50;
# proxy_pass http://web:8080;
# 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;
}
# proxy_redirect off;
# }

location /resolver {
rewrite ^/resolver(.*)$ $1 break;
Expand Down
8 changes: 0 additions & 8 deletions packages/billboard-client/Dockerfile

This file was deleted.

0 comments on commit bd36c0d

Please sign in to comment.