Skip to content

Commit

Permalink
feat(connector-go-ethereum): add the docker environment
Browse files Browse the repository at this point in the history
Signed-off-by: Takuma TAKEUCHI <takeuchi.takuma@fujitsu.com>
  • Loading branch information
takeutak authored and petermetz committed Oct 6, 2021
1 parent 62824be commit 2583cc7
Show file tree
Hide file tree
Showing 12 changed files with 394 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM hyperledger/fabric-tools:1.4

RUN apt-get update && apt-get upgrade -y && apt-get install -y software-properties-common gnupg
#RUN gnupg1 gnupg2

RUN apt-get install -y \
apt-utils \
apt-transport-https \
software-properties-common \
wget \
curl \
telnet \
sudo \
build-essential \
libffi-dev \
libssl-dev \
zlib1g-dev \
liblzma-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
git \
gnupg

# install python 3.9.5
#RUN apt-get install -y python3 python3-pip
#RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv
#RUN echo 'export PATH="$HOME"/.pyenv/bin:$PATH' >> ~/.rc
#RUN . ~/.rc && pyenv install 3.9.5
#RUN echo 'eval "$(pyenv init -)"' >> ~/.rc
#RUN echo 'eval "$(pyenv init --path)"' >> ~/.rc
#RUN cat ~/.rc >> ~/.bashrc
#RUN . ~/.rc && pyenv global 3.9.5

RUN apt-get install -y nodejs npm
RUN npm install n -g
RUN n 12
RUN apt purge -y nodejs npm

CMD [ "tail", "-f", "/dev/null" ]

COPY ./dist /root/cactus/dist/
COPY ./node_modules /root/cactus/node_modules/
COPY ./package.json /root/cactus/
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!--
Copyright 2021 Hyperledger Cactus Contributors
SPDX-License-Identifier: Apache-2.0
README.md
-->
# `@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio`

This plugin provides `Cactus` a way to interact with Go-Ethereum networks. Using this we can perform:
- `sendSyncRequest`: Send sync-typed requests to the ledgers (e.g. getBalance)
- `sendAsyncRequest`: Send async-typed requests to the ledgers (e.g. sendTransaction)
- `startMonitor`: Start monitoring blocks on the ledgers
- `stopMonitor`: Stop the block monitoring

## Summary
- [Getting started](#getting-started)
- [Usage samples](#usage-samples)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgments](#acknowledgments)

## Getting started

### Required software components
- OS: Linux (recommended Ubuntu20.04,18.04 or CentOS7)
- Docker (recommend: v17.06.2-ce or greater)
- Docker-compose (recommend: v1.14.0 or greater)
- node.js v12 (recommend: v12.20.2 or greater)

### Prerequisites
- Please ensure that the destination ledger (default: [geth-testnet](../../tools/docker/geth-testnet)) is already launched
- Available port: `5050` (for the port of `@hyperledger/cactus-plugin-ledger-connector-go-ethereum-socketio`)
- if this port is already used, please change the setting on `docker-compose.yaml`

### Boot methods

#### 1. Build the modules
- Install npm packages and build them
```
cd cactus/packages/cactus-plugin-ledger-connector-go-ethereum-socketio
npm install
npm run build
```
- Create symbolic link to node_modules
- NOTE: This command is enough to execute only once.
```
npm run init-ethereum
```

#### 2. Create the docker image
- Create the docker image
```
docker-compose -f docker-compose.yaml build
```

#### 3. Launch the container
- Launce the container
```
docker-compose -f docker-compose.yaml up
```

## Usage samples
- To confirm the operation of this package, please refer to the following business-logic sample applications:
- [electricity-trade](../../examples/electricity-trade)
- [car-trade](../../examples/cartrade)

## Contributing

We welcome contributions to Hyperledger Cactus in many forms, and there's always plenty to do!

Please review [CONTIRBUTING.md](../../CONTRIBUTING.md) to get started.

## License

This distribution is published under the Apache License Version 2.0 found in the [LICENSE](../../LICENSE) file.

## Acknowledgments
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/*
* Copyright 2020-2021 Hyperledger Cactus Contributors
* SPDX-License-Identifier: Apache-2.0
*
*
* copyStaticAssets.ts
*/
import * as shell from 'shelljs';
shell.cp('-R', 'src/main/typescript/common/core/CA/', './dist/common/core');
shell.cp('-R', 'src/main/typescript/common/core/validatorKey/', './dist/common/core');
import * as shell from "shelljs";
shell.cp("-R", "src/main/typescript/common/core/CA/", "./dist/common/core");
shell.cp(
"-R",
"src/main/typescript/common/core/validatorKey/",
"./dist/common/core"
);
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/*
* Copyright 2020-2021 Hyperledger Cactus Contributors
* SPDX-License-Identifier: Apache-2.0
*
*
* copyUtilityAssets.ts
*/
import * as shell from 'shelljs';
shell.cp('../cactus-cmd-socketio-server/src/main/typescript/verifier/ValidatorAuthentication.ts', './src/main/typescript/connector');
import * as shell from "shelljs";
shell.cp(
"../cactus-cmd-socketio-server/src/main/typescript/verifier/ValidatorAuthentication.ts",
"./src/main/typescript/connector"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: "3"
services:
hyperledger-cactus-plugin-ledger-connector-go-ethereum-socketio:
container_name: hyperledger-cactus-plugin-ledger-connector-go-ethereum-socketio
image: hyperledger-cactus-plugin-ledger-connector-go-ethereum-socketio
build:
context: ./
dockerfile: Dockerfile
args:
- HTTP_PROXY=$HTTP_PROXY
- http_proxy=$HTTP_PROXY
- HTTPS_PROXY=$HTTPS_PROXY
- https_proxy=$HTTP_PROXY
- FTP_PROXY=$HTTP_PROXY
- ftp_proxy=$HTTP_PROXY
- NO_PROXY=$NO_PROXY
- no_proxy=$NO_PROXY
ports:
- "5050:5050"
environment:
- HTTP_PROXY=$HTTP_PROXY
- http_proxy=$HTTP_PROXY
- HTTPS_PROXY=$HTTPS_PROXY
- https_proxy=$HTTP_PROXY
- FTP_PROXY=$HTTP_PROXY
- ftp_proxy=$HTTP_PROXY
- NO_PROXY=$NO_PROXY
- no_proxy=$NO_PROXY
working_dir: /root/cactus/
entrypoint: "npm run start"
#networks:
# - geth1net

networks:
default:
external:
name: geth1net
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
"web3": "^0.20.0"
},
"devDependencies": {
"typescript": "^3.9.3"
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.0",
"typescript": "^3.9.10"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ app.use(
err: { message: string; status?: number },
req: Request,
res: Response,
next: NextFunction,
next: NextFunction
) => {
// set locals, only providing error in development
res.locals.message = err.message;
Expand All @@ -47,7 +47,7 @@ app.use(
// render the error page
res.status(err.status || 500);
res.send(errorResponse);
},
}
);

export default app;
Loading

0 comments on commit 2583cc7

Please sign in to comment.