Skip to content

Commit 434cbf0

Browse files
committed
feat: added scripts
1 parent aede5aa commit 434cbf0

File tree

3 files changed

+236
-0
lines changed

3 files changed

+236
-0
lines changed

‎./workflows/dev.yml

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Deploys containers to the development environment.
2+
#
3+
name: Deploy to Staging
4+
on:
5+
push:
6+
branches:
7+
- dev
8+
env:
9+
_TOKEN: ${{ secrets._TOKEN }}
10+
DOCKER_ACTOR: ${{ secrets.DOCKER_ACTOR }}
11+
12+
jobs:
13+
14+
build-worker:
15+
name: Build deployer
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Login to docker registry
21+
run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
22+
- name: Docker push worker
23+
run: |
24+
docker build -t ghcr.io/eyblockchain/nightfall3-worker . -f worker.Dockerfile
25+
docker push ghcr.io/eyblockchain/nightfall3-worker
26+
27+
build-deployer:
28+
name: Build deployer
29+
runs-on: ubuntu-20.04
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
- name: Login to docker registry
34+
run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
35+
- name: Docker push deployer
36+
run: |
37+
docker build -t ghcr.io/eyblockchain/nightfall3-deployer . -f deployer.Dockerfile
38+
docker push ghcr.io/eyblockchain/nightfall3-deployer
39+
40+
build-optimist:
41+
name: Build optimist
42+
runs-on: ubuntu-20.04
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v2
46+
- name: Login to docker registry
47+
run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
48+
- name: Docker push optimist
49+
run: |
50+
docker build -t ghcr.io/eyblockchain/nightfall3-optimist . -f optimist.Dockerfile
51+
docker push ghcr.io/eyblockchain/nightfall3-optimist
52+
53+
build-proposer:
54+
name: Build proposer
55+
runs-on: ubuntu-20.04
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v2
59+
- name: Login to docker registry
60+
run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
61+
- name: Docker push proposer
62+
run: |
63+
docker build -t ghcr.io/eyblockchain/nightfall3-proposer . -f proposer.Dockerfile
64+
docker push ghcr.io/eyblockchain/nightfall3-proposer
65+
66+
# build-challenger:
67+
# name: Build challenger
68+
# runs-on: ubuntu-20.04
69+
# steps:
70+
# - name: Checkout
71+
# uses: actions/checkout@v2
72+
# - name: Login to docker registry
73+
# run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
74+
# - name: Docker push challenger
75+
# run: |
76+
# docker build -t ghcr.io/eyblockchain/nightfall3-challenger . -f challenger.Dockerfile
77+
# docker push ghcr.io/eyblockchain/nightfall3-challenger
78+
79+
# build-liquidity:
80+
# name: Build liquidity provider
81+
# runs-on: ubuntu-20.04
82+
# steps:
83+
# - name: Checkout
84+
# uses: actions/checkout@v2
85+
# - name: Login to docker registry
86+
# run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
87+
# - name: Docker push liqidity
88+
# run: |
89+
# docker build -t ghcr.io/eyblockchain/nightfall3-liquidity . -f liquidity.Dockerfile
90+
# docker push ghcr.io/eyblockchain/nightfall3-liquidity
91+
92+
deploy:
93+
name: Deploy
94+
runs-on: ubuntu-20.04
95+
needs: [build-deployer, build-optimist, build-proposer, build-challenger, build-liquidity]
96+
steps:
97+
- name: Checkout
98+
uses: actions/checkout@v2
99+
- name: Configure SSH
100+
run: |
101+
mkdir -p ~/.ssh/
102+
echo "$SSH_KEY" > ~/.ssh/dev.key
103+
chmod 600 ~/.ssh/dev.key
104+
cat >>~/.ssh/config <<END
105+
Host dev
106+
HostName $SSH_HOST
107+
User $SSH_USER
108+
IdentityFile ~/.ssh/dev.key
109+
StrictHostKeyChecking no
110+
END
111+
env:
112+
SSH_USER: pong
113+
SSH_KEY: ${{ secrets.DEV_SSH_KEY }}
114+
SSH_HOST: ohio.nightfall3.com
115+
- name: Copy files
116+
run: |
117+
scp dev.env pull-images.sh docker-compose.beta.yml dev
118+
ssh dev 'mv dev.env .env'
119+
ssh dev 'mv docker-compose.beta.yml docker-compose.yml'
120+
- name: Login to docker registry
121+
run: echo "${{ secrets._TOKEN }}" | docker login ghcr.io -u $DOCKER_ACTOR --password-stdin
122+
- name: Pull docker images
123+
run: ssh dev './pull-images'
124+
- name: Run up nightfall
125+
run: ssh 'docker-compose up -d deployer optimist'
126+
- name: Run up applications
127+
run: |
128+
ssh dev 'await-deployer'
129+
ssh dev 'docker-compose up -d proposer'

‎dev.env

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BLOCKCHAIN_WS_HOST=ropsten1-ws.testnet.nightfall3.com
2+
BLOCKCHAIN_PORT=80
3+
AUTOSTART_RETRIES=10000
4+
ETH_NETWORK=ropsten
5+
ETH_PRIVATE_KEY=abf4ed9f30bd1e4a290310d726c7bbdf39cd75a25eebd9a3a4874e10b4a0c4ce
6+
ETH_ADDRESS='0xdb080dC48961bC1D67a0A4151572eCb824cC76E8'
7+
TRANSACTIONS_PER_BLOCK=2
8+
PROPOSER_ETHEREUM_SIGNING_KEY=645ac79fa9fd87dd1cf30bdca51d326bd501cd328d6dbc9f5f517c7da0dafa6f

‎docker-compose.beta.yml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
version: '3.5'
2+
# Use this script to deploy nightfall_3 to dev, staging or prod
3+
#
4+
services:
5+
optimist:
6+
image: ghcr.io/eyblockchain/nightfall3-optimist:latest
7+
build:
8+
dockerfile: optimist.Dockerfile
9+
context: ./
10+
networks:
11+
- pong_network
12+
volumes:
13+
- type: volume
14+
source: build
15+
target: /app/build/
16+
environment:
17+
WEBSOCKET_PORT: 8080
18+
BLOCKCHAIN_WS_HOST: ${BLOCKCHAIN_WS_HOST}
19+
BLOCKCHAIN_PORT: ${BLOCKCHAIN_PORT}
20+
HASH_TYPE: mimc
21+
LOG_LEVEL: debug
22+
IS_CHALLENGER: 'true'
23+
TRANSACTIONS_PER_BLOCK: ${TRANSACTIONS_PER_BLOCK}
24+
AUTOSTART_RETRIES: ${AUTOSTART_RETRIES}
25+
26+
command: ['npm', 'run', 'dev']
27+
28+
# Temporary container to deploy contracts and circuits and populate volumes
29+
deployer:
30+
image: ghcr.io/eyblockchain/nightfall3-deployer:latest
31+
build:
32+
dockerfile: deployer.Dockerfile
33+
context: ./
34+
volumes:
35+
- type: volume
36+
source: build
37+
target: /app/build/
38+
networks:
39+
- pong_network
40+
environment:
41+
LOG_LEVEL: debug
42+
# ETH_NETWORK sets the network selected by Truffle from truffle-config.js
43+
# startup routines will wait for a blockchain client to be reachable on this network
44+
ETH_NETWORK: ${ETH_NETWORK}
45+
BLOCKCHAIN_WS_HOST: ${BLOCKCHAIN_WS_HOST}
46+
BLOCKCHAIN_PORT: ${BLOCKCHAIN_PORT}
47+
ZOKRATES_WORKER_HOST: worker
48+
USE_STUBS: 'false'
49+
ETH_PRIVATE_KEY: ${ETH_PRIVATE_KEY}
50+
ETH_ADDRESS: ${ETH_ADDRESS}
51+
GAS_PRICE: 20000000000
52+
# This is only needed for test purposes - it gives tokens to the user at startup
53+
#USER_ETHEREUM_ADDRESSES: 0xE35B7c8338E4B952C03E73B50f454B1df086fef2,0x4637Ee1126723e098A152f33F326fb767A6A2b8A
54+
55+
56+
worker:
57+
image: ghcr.io/eyblockchain/nightfall3-worker:latest
58+
build:
59+
dockerfile: worker.Dockerfile
60+
context: ./
61+
volumes:
62+
- type: volume
63+
source: proving_files
64+
target: /app/output/
65+
networks:
66+
- pong_network
67+
environment:
68+
LOG_LEVEL: info
69+
70+
proposer:
71+
image: ghcr.io/eyblockchain/nightfall3-proposer:latest
72+
build:
73+
dockerfile: proposer.Dockerfile
74+
context: ./
75+
networks:
76+
- pong_network
77+
environment:
78+
OPTIMIST_HOST: optimist
79+
OPTIMIST_WS_PORT: 8080
80+
OPTIMIST_HTTP_PORT: 80
81+
CLIENT_HOST: client
82+
CLIENT_PORT: 80
83+
BLOCKCHAIN_WS_HOST: ${BLOCKCHAIN_WS_HOST}
84+
BLOCKCHAIN_PORT: ${BLOCKCHAIN_PORT}
85+
PROPOSER_ETHEREUM_SIGNING_KEY: ${PROPOSER_ETHEREUM_SIGNING_KEY}
86+
87+
volumes:
88+
mongodb:
89+
proving_files:
90+
build:
91+
92+
networks:
93+
pong_network:
94+
driver: bridge
95+
ipam:
96+
driver: default
97+
config:
98+
- subnet: 172.16.239.0/24
99+
gateway: 172.16.239.1

0 commit comments

Comments
 (0)