Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/use-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ Check <https://hub.docker.com/r/nervos/perkins-tent>.

```bash
cd offchain-modules
# install node modules
yarn testnet-docker:install
# generate all configs
yarn testnet-docker:generate
# install and build force bridge inside docker
docker run --rm -v ${offchainModulePath}:/app -v force-bridge-node-modules:/app/node_modules node:14.18.1-bullseye bash -c 'cd /app && yarn build'

cd workdir/testnet-docker
docker-compose up -d
```
Expand Down
2 changes: 1 addition & 1 deletion offchain-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"startDevDockers": "docker-compose -f ../workdir/dev-docker/docker-compose.yml up -d --scale ui=0",
"startDevDockersWithUi": "docker-compose -f ../workdir/dev-docker/docker-compose.yml up -d",
"destroyDevDockers": "docker-compose -f ../workdir/dev-docker/docker-compose.yml down",
"testnet-docker:generate": "DOTENV_PATH=../workdir/testnet-docker/.env ts-node packages/scripts/src/testnetDocker.ts",
"testnet-docker:generate": "docker run --rm -e FORCE_BRIDGE_PROJECT_DIR=$(dirname \"$(pwd)\") -v $(dirname \"$(pwd)\"):/app -v force-bridge-node-modules:/app/offchain-modules/node_modules node:14.18.1-bullseye bash -c 'cd /app/offchain-modules && DOTENV_PATH=../workdir/testnet-docker/.env npx ts-node packages/scripts/src/testnetDocker.ts'",
"testnet-docker:install": "docker run --rm -v $(pwd):/app -v force-bridge-node-modules:/app/node_modules node:14.18.1-bullseye bash -c 'cd /app && yarn build'"
},
"author": "",
Expand Down
20 changes: 12 additions & 8 deletions offchain-modules/packages/scripts/src/testnetDocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import * as lodash from 'lodash';
import * as Mustache from 'mustache';
import { execShellCmd, PATH_PROJECT_ROOT, pathFromProjectRoot } from './utils';
import { deployDev } from './utils/deploy';
import { nonNullable } from '@force-bridge/x';

dotenv.config({ path: process.env.DOTENV_PATH || '.env' });

export interface VerifierConfig {
Expand Down Expand Up @@ -140,7 +142,7 @@ const dockerComposeTemplate = `
version: "3.3"
services:
script:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
volumes:
- ./script:/data
Expand All @@ -163,7 +165,7 @@ services:
ports:
- 3050:3306
watcher:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
FORCE_BRIDGE_KEYSTORE_PASSWORD: {{FORCE_BRIDGE_KEYSTORE_PASSWORD}}
Expand All @@ -188,7 +190,7 @@ services:
ports:
- 3059:3306
collector:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
FORCE_BRIDGE_KEYSTORE_PASSWORD: {{FORCE_BRIDGE_KEYSTORE_PASSWORD}}
Expand All @@ -214,7 +216,7 @@ services:
ports:
- {{db_port}}:3306
{{name}}:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
FORCE_BRIDGE_KEYSTORE_PASSWORD: {{FORCE_BRIDGE_KEYSTORE_PASSWORD}}
Expand All @@ -233,7 +235,7 @@ services:
- {{name}}_db
{{/verifiers}}
monitor:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
MONITOR_DURATION_CONFIG_PATH: /data/monitor.json
Expand All @@ -254,6 +256,8 @@ volumes:
async function main() {
initLog({ level: 'debug', identity: 'testnet-docker' });
// used for deploy and run service
// passed through: docker run -e FORCE_BRIDGE_PROJECT_DIR=$(dirname "$(pwd)")
nonNullable(process.env.FORCE_BRIDGE_PROJECT_DIR);
const CKB_RPC_URL = getFromEnv('CKB_RPC_URL');
const ETH_RPC_URL = getFromEnv('ETH_RPC_URL');
const CKB_INDEXER_URL = getFromEnv('CKB_INDEXER_URL');
Expand Down Expand Up @@ -293,7 +297,7 @@ async function main() {
},
eth: {
rpcUrl: ETH_RPC_URL,
confirmNumber: 12,
confirmNumber: 12, // 1 if Bsc
startBlockHeight: 1,
batchUnlock: {
batchNumber: 100,
Expand All @@ -305,7 +309,7 @@ async function main() {
ckbIndexerUrl: CKB_INDEXER_URL,
startBlockHeight: 1,
confirmNumber: 15,
sudtSize: 150,
sudtSize: 400,
},
};

Expand Down Expand Up @@ -354,7 +358,7 @@ async function main() {
await execShellCmd(`mkdir -p ${path.join(configPath, 'script')}`);
const dockerComposeFile = Mustache.render(dockerComposeTemplate, {
FORCE_BRIDGE_KEYSTORE_PASSWORD,
projectDir: PATH_PROJECT_ROOT,
projectDir: process.env.FORCE_BRIDGE_PROJECT_DIR,
verifiers,
});
fs.writeFileSync(path.join(configPath, 'docker-compose.yml'), dockerComposeFile);
Expand Down