Skip to content

Commit 4df9314

Browse files
committed
chore: separate script to start chain
1 parent 5ae1a44 commit 4df9314

File tree

9 files changed

+63
-28
lines changed

9 files changed

+63
-28
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"onAutoForward": "silent"
1919
}
2020
},
21-
"postStartCommand": "/bin/bash /workspaces/dapp-offer-up/make_ports_public.sh 26657 1317",
21+
"postStartCommand": "/bin/bash /ws-offerups/dapp-offer-up/make_ports_public.sh 26657 1317",
2222
"features": {
2323
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
2424
"ghcr.io/devcontainers/features/github-cli:1": {}

contract/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"description": "Offer Up Contract",
66
"type": "module",
77
"scripts": {
8-
"start:docker": "docker compose up -d",
9-
"docker:logs": "docker compose logs --tail 200 -f",
10-
"docker:bash": "docker compose exec agd bash",
11-
"docker:make": "docker compose exec agd make -C /workspace/contract",
8+
"start:docker": "./scripts/start_chain.sh",
9+
"docker:logs": "docker logs --tail 200 -f agdc",
10+
"docker:bash": "docker exec -it agdc bash",
11+
"docker:make": "docker exec agdc make -C /ws-offerup/contract",
1212
"make:help": "make list",
1313
"start": "./scripts/wait-for-chain.sh && yarn docker:make clean start-contract",
1414
"build": "agoric run scripts/build-contract-deployer.js",

contract/scripts/build-proposal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# NOTE: intended to run _inside_ the agd container
33

4-
cd /workspace/contract
4+
cd /ws-offerup/contract
55

66
mkdir -p bundles
77
(agoric run ./scripts/build-contract-deployer.js )>/tmp/,run.log

contract/scripts/install-bundles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -ueo pipefail
55

66
. /usr/src/upgrade-test-scripts/env_setup.sh
77

8-
cd /workspace/contract
8+
cd /ws-offerup/contract
99

1010
# wait for blocks to start being produced
1111
# avoid collision with run-chain.sh who is also migrating keys

contract/scripts/propose-start-contract.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -xueo pipefail
33

4-
cd /workspace/contract
4+
cd /ws-offerup/contract
55

66
SCRIPT=start-offer-up.js
77
PERMIT=start-offer-up-permit.json

contract/scripts/run-chain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# wait for blocks to start being produced
99
waitForBlock 1
1010

11-
make -C /workspace/contract mint100
11+
make -C /ws-offerup/contract mint100
1212

1313
# bring back chain process to foreground
1414
wait

contract/scripts/start_chain.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -e # Exit on error
3+
4+
# Check if script has execute permissions
5+
if [ ! -x "$(pwd)/contract/scripts/run-chain.sh" ]; then
6+
echo "Adding execute permissions to run-chain.sh..."
7+
chmod +x "$(pwd)/contract/scripts/run-chain.sh"
8+
fi
9+
10+
# Check if container already exists and is running
11+
if [ "$(docker ps -q -f name=agdc)" ]; then
12+
echo "Container 'agdc' is already running. Please stop it first using 'docker stop agdc' if you want to start a new instance."
13+
exit 1
14+
fi
15+
16+
# Check if container exists but is stopped
17+
if [ "$(docker ps -aq -f status=exited -f name=agdc)" ]; then
18+
echo "Found stopped container 'agdc'. Removing it before starting a new one..."
19+
docker rm agdc
20+
fi
21+
22+
# Set paths only if environment variables are not already set
23+
: ${DAPP_ED_CERT_PATH:="$(pwd)/../dapp-ed-cert"}
24+
: ${DAPP_CHAIN_TIMER_PATH:="$(pwd)/../dapp-chain-timer"}
25+
: ${SECOND_INVITE_PATH:="$(pwd)/../dapp-second-invite"}
26+
: ${DAPP_OFFER_UP_PATH:="$(pwd)/../dapp-offer-up"}
27+
: ${DAPP_AGORIC_BASICS_PATH:="$(pwd)/../dapp-agoric-basics"}
28+
29+
# Start new container
30+
docker run -d \
31+
--name agdc \
32+
--platform linux/amd64 \
33+
-p 26656:26656 \
34+
-p 26657:26657 \
35+
-p 1317:1317 \
36+
-e DEST=1 \
37+
-e DEBUG="SwingSet:ls,SwingSet:vat" \
38+
$([ -d "$DAPP_ED_CERT_PATH" ] && echo "-v $DAPP_ED_CERT_PATH:/ws-edcert") \
39+
$([ -d "$DAPP_CHAIN_TIMER_PATH" ] && echo "-v $DAPP_CHAIN_TIMER_PATH:/ws-chainTimer") \
40+
$([ -d "$SECOND_INVITE_PATH" ] && echo "-v $SECOND_INVITE_PATH:/ws-secondInvite") \
41+
$([ -d "$DAPP_OFFER_UP_PATH" ] && echo "-v $DAPP_OFFER_UP_PATH:/ws-offerup") \
42+
$([ -d "$DAPP_AGORIC_BASICS_PATH" ] && echo "-v $DAPP_AGORIC_BASICS_PATH:/ws-agoricBasics") \
43+
ghcr.io/agoric/agoric-3-proposals:latest \
44+
/ws-edcert/contract/scripts/run-chain.sh || {
45+
echo "Failed to start docker container. Please check if Docker is running and you have necessary permissions."
46+
exit 1
47+
}
48+
49+
echo "Container 'agdc' started successfully."

docker-compose.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
"@babel/highlight": "7.22.5"
4040
},
4141
"scripts": {
42-
"start:docker": "cd contract && docker compose up -d",
43-
"docker:logs": "cd contract; docker compose logs --tail 200 -f",
44-
"docker:bash": "cd contract; docker compose exec agd bash",
45-
"docker:make": "cd contract; docker compose exec agd make -C /workspace/contract",
42+
"start:docker": "./contract/scripts/start_chain.sh",
43+
"stop:docker": "cd contract && docker stop agdc && docker rm agdc",
44+
"docker:logs": "cd contract && docker logs -f --tail 200 agdc",
45+
"docker:bash": "cd contract && docker exec -it agdc bash",
46+
"docker:make": "cd contract && docker exec agdc make ",
4647
"make:help": "make -C contract list",
4748
"start:contract": "cd contract && yarn start",
4849
"start:ui": "cd ui && yarn dev",

0 commit comments

Comments
 (0)