Skip to content

Commit 789268a

Browse files
committed
build: docker compose
1 parent 1943a6d commit 789268a

File tree

15 files changed

+194
-68
lines changed

15 files changed

+194
-68
lines changed

.github/workflows/deploy.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Push Workflow
2+
on: push
3+
4+
jobs:
5+
messenger-demo-deploy:
6+
runs-on: ubuntu-latest
7+
if: github.ref == 'refs/heads/${{ vars.STAGING_BRANCH }}'
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-node@v3
11+
with:
12+
registry-url: 'https://npm.pkg.github.com'
13+
node-version: 18.0.0
14+
cache: 'yarn'
15+
- name: Prepare SSH
16+
run: |
17+
mkdir ~/.ssh
18+
echo "${{ secrets.STAGING_HOST_SSH }}" > ~/.ssh/known_hosts
19+
echo "${{ secrets.DO_SSH_KEY }}" > ./ssh-key
20+
chmod 600 ./ssh-key
21+
- name: Create .env file
22+
run: |
23+
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.beta-addr.dm3.eth" >> ./.env
24+
echo "REACT_APP_BACKEND=http://${{ secrets.STAGING_HOST }}" >> ./.env
25+
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./.env
26+
echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.STAGING_HOST }}" >> ./.env
27+
echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.REACT_APP_ETHEREUM_PROVIDER }}" >> ./.env
28+
echo "REACT_APP_PROFILE_BASE_URL=http://dm3-beta2-resolver.herokuapp.com" >> ./.env
29+
echo "REACT_APP_RESOLVER_BACKEND=http://dm3-beta2-resolver.herokuapp.com" >> ./.env
30+
echo "REACT_APP_USER_ENS_SUBDOMAIN=.beta-user.dm3.eth" >> ./.env
31+
echo "REACT_APP_WALLET_CONNECT_PROJECT_ID=${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}" >> ./.env
32+
echo "RESOLVER_ADDR=0x45F7Ed7d05c563D408898A80d9C705CC3328D2EF" >> ./.env
33+
echo WEB_PORT=80 >> ./.env
34+
- name: Sync files
35+
run: |
36+
rsync -avz -e 'ssh -i ./ssh-key' ./.env app@${{ secrets.STAGING_HOST }}:/home/app/
37+
rsync -avz -e 'ssh -i ./ssh-key' ./docker/docker-compose.yml app@${{ secrets.STAGING_HOST }}:/home/app/

.github/workflows/on-push.yml

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: push
44
jobs:
55
code-quality:
66
runs-on: ubuntu-latest
7+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
78
steps:
89
- uses: actions/checkout@v2
910
- uses: actions/setup-node@v3
@@ -22,7 +23,7 @@ jobs:
2223

2324
build:
2425
runs-on: ubuntu-latest
25-
26+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
2627
steps:
2728
- uses: actions/checkout@v2
2829
- uses: actions/setup-node@v3
@@ -50,6 +51,7 @@ jobs:
5051
path: packages/lib/**/schema/
5152
backend-test:
5253
runs-on: ubuntu-latest
54+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
5355
needs: build
5456
defaults:
5557
run:
@@ -63,6 +65,7 @@ jobs:
6365
package-pat: ${{ secrets.PACKAGE_PAT }}
6466
integration-test:
6567
runs-on: ubuntu-latest
68+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
6669
needs: build
6770
defaults:
6871
run:
@@ -76,6 +79,7 @@ jobs:
7679
package-pat: ${{ secrets.PACKAGE_PAT }}
7780
lib-crypto-test:
7881
runs-on: ubuntu-latest
82+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
7983
needs: build
8084
defaults:
8185
run:
@@ -89,6 +93,7 @@ jobs:
8993
package-pat: ${{ secrets.PACKAGE_PAT }}
9094
lib-delivery-test:
9195
runs-on: ubuntu-latest
96+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
9297
needs: build
9398
defaults:
9499
run:
@@ -102,6 +107,7 @@ jobs:
102107
package-pat: ${{ secrets.PACKAGE_PAT }}
103108
lib-messaging-test:
104109
runs-on: ubuntu-latest
110+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
105111
needs: build
106112
defaults:
107113
run:
@@ -115,6 +121,7 @@ jobs:
115121
package-pat: ${{ secrets.PACKAGE_PAT }}
116122
lib-profile-test:
117123
runs-on: ubuntu-latest
124+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
118125
needs: build
119126
defaults:
120127
run:
@@ -128,6 +135,7 @@ jobs:
128135
package-pat: ${{ secrets.PACKAGE_PAT }}
129136
lib-shared-test:
130137
runs-on: ubuntu-latest
138+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
131139
needs: build
132140
defaults:
133141
run:
@@ -141,6 +149,7 @@ jobs:
141149
package-pat: ${{ secrets.PACKAGE_PAT }}
142150
lib-storage-test:
143151
runs-on: ubuntu-latest
152+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
144153
needs: build
145154
defaults:
146155
run:
@@ -154,6 +163,7 @@ jobs:
154163
package-pat: ${{ secrets.PACKAGE_PAT }}
155164
offchain-resolver-test:
156165
runs-on: ubuntu-latest
166+
if: github.ref != 'refs/heads/${{ vars.STAGING_BRANCH }}'
157167
needs: build
158168
defaults:
159169
run:
@@ -164,53 +174,4 @@ jobs:
164174
uses: ./test-action
165175
with:
166176
workspace-name: 'dm3-offchain-resolver'
167-
package-pat: ${{ secrets.PACKAGE_PAT }}
168-
messenger-demo-deploy:
169-
runs-on: ubuntu-latest
170-
if: github.ref == 'refs/heads/new-ui'
171-
steps:
172-
# Check-out your repository.
173-
- name: Checkout
174-
uses: actions/checkout@v2
175-
- name: Create env file
176-
run: |
177-
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.beta-addr.dm3.eth" >> ./packages/messenger-demo/.env
178-
echo "REACT_APP_BACKEND=https://dm3-beta2.herokuapp.com" >> ./packages/messenger-demo/.env
179-
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./packages/messenger-demo/.env
180-
echo "REACT_APP_DEFAULT_SERVICE=https://dm3-beta2.herokuapp.com" >> ./packages/messenger-demo/.env
181-
echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.REACT_APP_ETHEREUM_PROVIDER }}" >> ./packages/messenger-demo/.env
182-
echo "REACT_APP_PROFILE_BASE_URL=https://dm3-beta2-resolver.herokuapp.com" >> ./packages/messenger-demo/.env
183-
echo "REACT_APP_RESOLVER_BACKEND=https://dm3-beta2-resolver.herokuapp.com" >> ./packages/messenger-demo/.env
184-
echo "REACT_APP_USER_ENS_SUBDOMAIN=.beta-user.dm3.eth" >> ./packages/messenger-demo/.env
185-
echo "REACT_APP_WALLET_CONNECT_PROJECT_ID=${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}" >> ./packages/messenger-demo/.env
186-
echo "RESOLVER_ADDR=0x45F7Ed7d05c563D408898A80d9C705CC3328D2EF" >> ./packages/messenger-demo/.env
187-
- name: Build, Push and Release a Docker container to Heroku. # Your custom step name
188-
uses: gonuit/[email protected] # GitHub action name (leave it as it is).
189-
with:
190-
# Below you must provide variables for your Heroku app.
191-
192-
# The email address associated with your Heroku account.
193-
# If you don't want to use repository secrets (which is recommended) you can do:
194-
195-
email: ${{ secrets.HEROKU_EMAIL }}
196-
197-
# Heroku API key associated with provided user's email.
198-
# Api Key is available under your Heroku account settings.
199-
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
200-
201-
# Name of the heroku application to which the build is to be sent.
202-
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
203-
204-
# (Optional, default: "./")
205-
# Dockerfile directory.
206-
# For example, if you have a Dockerfile in the root of your project, leave it as follows:
207-
dockerfile_directory: ./
208-
209-
# (Optional, default: "Dockerfile")
210-
# Dockerfile name.
211-
dockerfile_name: ./packages/messenger-demo/Dockerfile
212-
# (Optional, default: "web")
213-
# Select the process type for which you want the docker container to be uploaded.
214-
# By default, this argument is set to "web".
215-
# For more information look at https://devcenter.heroku.com/articles/process-model
216-
process_type: web
177+
package-pat: ${{ secrets.PACKAGE_PAT }}

docker/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM --platform=linux/amd64 node:18-alpine
2+
WORKDIR /app
3+
COPY . .
4+
RUN apk add --update python3 make g++\
5+
&& rm -rf /var/cache/apk/*
6+
RUN yarn install
7+
RUN yarn build

docker/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
docker build --progress=plain -t dm3-backend -f ./docker/Dockerfile .

docker/docker-compose.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: "3.1"
2+
services:
3+
4+
backend:
5+
image: dm3org/dm3-backend:v0.2.1
6+
command: yarn workspace dm3-backend start
7+
depends_on:
8+
- db
9+
environment:
10+
- REDIS_URL=redis://db:6379
11+
12+
db:
13+
image: redis
14+
restart: always
15+
16+
offchain-resolver-db:
17+
image: postgres
18+
restart: always
19+
container_name: offchain_resolver_db
20+
environment:
21+
POSTGRES_PASSWORD: example
22+
ports:
23+
- '5432:5432'
24+
25+
offchain-resolver:
26+
image: dm3org/dm3-backend:v0.2.1
27+
command: yarn workspace dm3-offchain-resolver start
28+
depends_on:
29+
- offchain-resolver-db
30+
environment:
31+
DATABASE_URL: postgresql://postgres:example@offchain-resolver-db:5432
32+
ports:
33+
- '8082:8082'
34+
35+
web:
36+
image: dm3org/dm3-backend:v0.2.1
37+
command: yarn workspace messenger-demo start
38+
ports:
39+
- '8080:${WEB_PORT}'
40+
41+
ccip-resolver:
42+
image: dm3org/ccip-resolver:v0.2.2
43+
restart: always
44+
depends_on:
45+
- offchain-resolver
46+
environment:
47+
SIGNER_PRIVATE_KEY: ${SIGNER_PRIVATE_KEY}
48+
LOG_LEVEL: debug
49+
CONFIG: |
50+
{
51+
"0x5e0F81D5ca51D309B3A046FAeea70C4C70Df8079": {
52+
"type": "signing",
53+
"handlerUrl": "http://offchain-resolver:8081"
54+
}
55+
}
56+
PORT: 8181
57+
ports:
58+
- '8181:8181'

packages/backend/Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
FROM node:18-alpine
22
WORKDIR /app
33
COPY . .
4-
4+
RUN apk add --update python3 make g++\
5+
&& rm -rf /var/cache/apk/*
6+
RUN ls
7+
RUN pwd
58
RUN yarn install
6-
# RUN yarn build
7-
CMD cd packages/backend && yarn start
8-
EXPOSE 3000
9+
RUN yarn build
10+
CMD yarn workspace messenger-demo start

packages/backend/src/persistance/getDatabase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function getRedisClient(logger: winston.Logger) {
3636
url,
3737
...socketConf,
3838
}
39-
: {},
39+
: { url },
4040
);
4141

4242
client.on('error', (err) => {

packages/billboard-client/src/persitance/getDatabase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function getRedisClient(logger: winston.Logger) {
2222
url,
2323
...socketConf,
2424
}
25-
: {},
25+
: { url },
2626
);
2727

2828
client.on('error', (err) => {

packages/offchain-resolver/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"scripts": {
2727
"docker:up": "docker-compose up -d",
2828
"test": "yarn docker:up && yarn prisma:migrate && yarn mocha --require ts-node/register --extension .test.ts --recursive ./src",
29-
"start": "yarn ts-node --transpile-only ./src/index.ts",
29+
"start:dev": "yarn prisma:migrate && yarn ts-node --transpile-only ./src/index.ts",
30+
"start": "yarn prisma:migrate && node ./dist",
3031
"build": "yarn prisma generate --schema=./src/persistance/schema.prisma && yarn tsc",
3132
"prisma:migrate": "yarn prisma migrate dev --name init --schema src/persistance/schema.prisma"
3233
},

packages/offchain-resolver/src/http/handleCcipRequest/encoding/decodeRequest.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DecodedCcipRequest } from '../types';
33
import { decodeAddr } from './decode/decodeAddr';
44
import { decodeText } from './decode/decodeText';
55
import { getResolverInterface } from './getResolverInterface';
6+
import { TransactionDescription } from 'ethers/lib/utils';
67

78
/**
89
Decodes a given calldata string and returns a DecodedCcipRequest object containing the signature and request.
@@ -14,14 +15,16 @@ export function decodeRequest(calldata: string): DecodedCcipRequest {
1415
try {
1516
const textResolver = getResolverInterface();
1617

17-
//Parse the calldata returned by a contra
18-
const [ensName, data] = textResolver.parseTransaction({
19-
data: calldata,
20-
}).args;
18+
//Parse the calldata returned by a contrat
19+
const [ensName, data] = (
20+
textResolver.parseTransaction({
21+
data: calldata,
22+
}) as TransactionDescription
23+
).args;
2124

2225
const { signature, args } = textResolver.parseTransaction({
2326
data,
24-
});
27+
}) as TransactionDescription;
2528

2629
switch (signature) {
2730
case 'text(bytes32,string)':

packages/offchain-resolver/src/http/handleCcipRequest/encoding/getResolverInterface.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,32 @@ import { ethers } from 'ethers';
22

33
export function getResolverInterface() {
44
return new ethers.utils.Interface([
5-
'function resolve(bytes calldata name, bytes calldata data) external view returns(bytes)',
5+
// eslint-disable-next-line max-len
6+
'function resolveWithContext(bytes calldata name,bytes calldata data,bytes calldata context) external view returns (bytes memory result)',
7+
// eslint-disable-next-line max-len
8+
'function resolveWithProof(bytes calldata response, bytes calldata extraData) external view returns (bytes memory)',
9+
//Text
610
'function text(bytes32 node, string calldata key) external view returns (string memory)',
11+
//Address
712
'function addr(bytes32 node) external view returns (address)',
13+
//ABI
14+
// eslint-disable-next-line max-len
15+
'function ABI(bytes calldata context,bytes32 node,uint256 contentTypes) external view returns(uint256, bytes memory)',
16+
//ContentHash
17+
'function contenthash(bytes calldata context, bytes32 node) external view returns (bytes memory)',
18+
'function contenthash(bytes32 node) external view returns (bytes memory)',
19+
//Interface
20+
// eslint-disable-next-line max-len
21+
'function interfaceImplementer (bytes calldata context, bytes32 node, bytes4 interfaceID) external view returns (address)',
22+
//Name
23+
24+
'function name(bytes calldata context ,bytes32 node) external view returns (string memory)',
25+
//Pubkey
26+
'function pubkey(bytes calldata context ,bytes32 node) external view returns (bytes memory x, bytes memory y)',
27+
//DNS
28+
// eslint-disable-next-line max-len
29+
'function dnsRecord(bytes calldata context,bytes32 node,bytes32 name,uint16 resource) public view returns(bytes memory)',
30+
'function hasDNSRecords(bytes calldata context, bytes32 node, bytes32 name) public view returns (bool)',
31+
'function zonehash(bytes calldata context, bytes32 node) external view returns (bytes memory)',
832
]);
933
}

packages/offchain-resolver/src/http/handleCcipRequest/handleCcipRequest.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import express from 'express';
22
import { handleAddr } from './handler/handleAddr';
33
import { handleText } from './handler/resolveText';
4+
import { ethers } from 'ethers';
45
export async function handleCcipRequest(
56
req: express.Request,
67
signature: string,
@@ -9,7 +10,10 @@ export async function handleCcipRequest(
910
switch (signature) {
1011
case 'text(bytes32,string)':
1112
req.app.locals.logger.info('Reading text(bytes32,string)');
12-
return await handleText(req.app.locals.db, request);
13+
return ethers.utils.defaultAbiCoder.encode(
14+
['string'],
15+
[await handleText(req.app.locals.db, request)],
16+
);
1317
case 'addr(bytes32)':
1418
req.app.locals.logger.info('Reading addr(bytes32))');
1519
return await handleAddr(req.app.locals.db, request);

packages/offchain-resolver/src/http/resolverEndpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function resolverEndpoint() {
3434

3535
res.status(404).send({ message: 'Record not found' });
3636
} else {
37-
res.send({ response });
37+
res.send(response);
3838
}
3939
} catch (e) {
4040
req.app.locals.logger.warn((e as Error).message);

0 commit comments

Comments
 (0)