Also, the database used by Ganache for storing blockchain information is placed in the path
`/mnt/concordia/ganache_db/`. You can maintain the blockchain state between runs by mounting a volume to the database
path. To do that, add the docker flag `-v host/absolute/path/to/ganache_db:/mnt/concordia/ganache_db`.
### Rendezvous
The rendezvous server used here is `js-libp2p-webrtc-star`. The server listens on port 9090. More information can be
found on the github page of the project [here](https://github.com/libp2p/js-libp2p-webrtc-star).
### Contracts provider
A Dockerfile for the contracts provider service is provided in the path `./concordia-contracts-provider`. The Dockerfile
contains only one stage, that is the runtime.
The image makes use of the environment variables described below.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| CONTRACTS_PROVIDER_PORT | `8400` | Set the port of the contracts provider application |
| UPLOAD_CONTRACTS_DIRECTORY | `concordia/packages/concordia-contracts-provider/contracts-uploads` | Set the directory where the uploaded contracts are saved |
| LOGS_PATH | `concordia/packages/concordia-contracts-provider/logs` | Set the directory where the application logs are saved |
| CORS_ALLOWED_ORIGINS | `http://127.0.0.1:7000`, `http://localhost:7000`, `https://127.0.0.1:7000`, `https://localhost:7000`, `http://127.0.0.1:4444`, `http://localhost:4444`, `https://127.0.0.1:4444`, `https://localhost:4444` | Set the list of addresses allowed by CORS* |
### Contracts
This is a provision system that compiles and deploys the contracts to any Ethereum blockchain.
This is a provision system that compiles and deploys the contracts to any Ethereum blockchain. It also uploads the
deployed contract artifacts to the contracts-provider service.
**Attention**: the contracts-provider instance targeted by the environment variables MUST be up and running before
attempting to migrate the contracts.
A Dockerfile is provided in the path `./concordia-contracts` that will build the contracts used by Concordia and
handle their deployment to any Ethereum network defined using env-vars upon container run. Dockerfile contains three
useful stages, described in the table below.
A Dockerfile is provided in the path `./concordia-contracts` that will build the contracts used by Concordia during
image build and handle their deployment to any Ethereum network defined using env-vars upon container run. Dockerfile
contains three useful stages, described in the table below.
| Stage name | Entrypoint | Usage |
| --- | --- | --- |
@ -78,41 +106,71 @@ The image makes use of the environment variables described below.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| MIGRATE_NETWORK | develop | Set the network where the contracts will be deployed/tested (set this to "env" unless you know what you're doing) |
| DEPLOY_CHAIN_HOST | NaN | Set the hostname of the blockchain network that will be used for deployment (requires network to be "env") |
| DEPLOY_CHAIN_PORT | NaN | Set the port of the blockchain network that will be used for deployment (requires network to be "env") |
| TEST_CHAIN_HOST | NaN | Set the hostname of the blockchain network that will be used for testing (requires network to be "env") |
| TEST_CHAIN_PORT | NaN | Set the port of the blockchain network that will be used for testing (requires network to be "env") |
| MIGRATE_NETWORK | `develop` | Set the network where the contracts will be deployed/tested (set this to "env" unless you know what you're doing) |
| WEB3_HOST | `127.0.0.1` | Set the hostname of the blockchain network that will be used for deployment (requires network to be "env") |
| WEB3_PORT | `8545` | `NaN` | Set the port of the blockchain network that will be used for deployment (requires network to be "env") |
| CONTRACTS_PROVIDER_HOST | `http://127.0.0.1` | Set the hostname of the contracts provider |
| CONTRACTS_PROVIDER_PORT | `8400` | Set the port of the contracts provider |
| CONTRACTS_VERSION_TAG | `NaN` | Set the tag of the contracts uploaded to provided |
You can find the contract artifacts in the directory `/usr/src/concordia/packages/concordia-contracts/build/` inside
the image.
**Attention**: make sure the targeted blockchain is up and running before trying to migrate the contracts.
### Pinner
A Dockerfile for the pinner service is provided in the path `./concordia-pinner`. The Dockerfile contains only one
stage, that is the runtime.
The image makes use of the environment variables described below.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| PINNER_API_HOST | `127.0.0.1` | Set the hostname of the pinner application |
| PINNER_API_PORT | `4444` | Set the port of the pinner application |
| USE_EXTERNAL_CONTRACTS_PROVIDER | `false` | Enable/Disable use of external contracts provider |
| IPFS_DIRECTORY | `concordia/packages/concordia-pinner/ipfs` | Set the directory where the ipfs blocks are saved |
| ORBIT_DIRECTORY | `concordia/packages/concordia-pinner/orbitdb` | Set the directory where the orbitdb data are saved |
| LOGS_PATH | `concordia/packages/concordia-pinner/logs` | Set the directory where the application logs are saved |
| WEB3_HOST | `127.0.0.1` | Set the hostname of the blockchain |
| WEB3_PORT | `8545` | Set the port of the blockchain |
| RENDEZVOUS_HOST | `/ip4/127.0.0.1` | Set the hostname of the rendezvous server |
| RENDEZVOUS_PORT | `9090` | Set the port of the rendezvous server |
| CONTRACTS_PROVIDER_HOST | `http://127.0.0.1` | Set the hostname of the contracts provider service |
| CONTRACTS_PROVIDER_PORT | `8400` | Set the port of the contracts provider service |
| CONTRACTS_VERSION_HASH | `latest` | Set the contracts tag that will be pulled |
### Application
The Dockerfile provided in the path `./concordia-application` builds the application for production and serves
the resulting build using an nginx server. Dockerfile contains two useful stages, described in the table below.
The Dockerfile provided in the path `./concordia-application` either builds the application for production and serves
the resulting build using an nginx server or simply runs the node development server. Dockerfile contains four stages,
described in the table below.
| Stage name | Entrypoint | Usage |
| --- | --- | --- |
| test | Runs tests | Fetches npm packages and runs tests |
| runtime | Serves application | Builds for production and serves it through nginx |
| staging | Serves application for development | Starts the node development server |
| runtime | Serves application for production | Builds for production and serves it through nginx |
The image makes use of the environment variables described below.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| REACT_APP_RENDEZVOUS_HOST | 127.0.0.1 | Set the hostname of the rendezvous server |
| REACT_APP_RENDEZVOUS_PORT | 9090 | Set the port of the rendezvous server |
| REACT_APP_CONCORDIA_HOST | `127.0.0.1` | Set the hostname of the concordia application |
| REACT_APP_CONCORDIA_PORT | `7000` | Set the port of the concordia application |
| REACT_APP_RENDEZVOUS_HOST | `/ip4/127.0.0.1` | Set the hostname of the rendezvous server |
| REACT_APP_RENDEZVOUS_PORT | `9090` | Set the port of the rendezvous server |
| REACT_APP_USE_EXTERNAL_CONTRACTS_PROVIDER | `false` | Enable/Disable use of external contracts provider |
| REACT_APP_CONTRACTS_PROVIDER_HOST | `http://127.0.0.1` | Set the hostname of the contracts provider service |
| REACT_APP_CONTRACTS_PROVIDER_PORT | `8400` | Set the port of the contracts provider service |
| REACT_APP_CONTRACTS_VERSION_HASH | `latest` | Set the contracts tag that will be pulled |
**Attention**: this image will copy the contract artifacts from the directory `/packages/concordia-contracts/build`.
The image is bound the these artifacts after build. If the contracts change or get re-deployed the image must be
re-built to use the new artifacts.
**Attention**: this image will copy the contract artifacts from the directory `/packages/concordia-contracts/build` if
available. The image can then use these artifacts after build or pull new artifacts from a contracts provider.
**Attention**: make sure the contracts have been deployed before **building** this image. Also, make sure the rendezvous
server is up and running.
**Attention**: if you plan to use the imported contract artifacts instead of a provider, make sure the contracts have
been deployed before **building** this image. Also, make sure the rendezvous server is up and running.
## Docker Compose
@ -194,11 +252,11 @@ the hood is that:
### Env Files
Targets in the Makefile make use of env files suffixed by `.docker`located in the directory `./env`. Using this
environment variables, you can change various configuration options of the testing/production deploys.
Targets in the Makefile make use of env files located in the directory `./env`. Using this environment variables, you
can change various configuration options of the testing/production deploys.
Targets suffixed with `host-chain` will try to use a blockchain and rendezvous server running in the host machine. They
use the `--net=host` docker option and get the required environment variables from different env files,
`./env/contracts.env` and `./env/concordia.env` (notice these env files don't include the `.docker`). These env files do
not exist by default. The values set will largely depend on how you choose to run services in your system (which ports
you use etc.), so be sure to create them before running any `host-chain`target. Luckily example files are provided.
Makefile targets suffixed with `host-chain` will try to use a blockchain and rendezvous server running in the host
machine. They use the `--net=host` docker option. In order to work with these targets you need to create and use your
own env files (or modify the existing ones). The environment variables values will largely depend on how you choose to
run the services in your system (which ports you use etc.), so be sure to create them before running any `host-chain`
Contracts provider is a **very** simple resource provider server that handles saving the contract artifacts produced
during contracts migration and serving them to the users (and pinner).
## Running Concordia
To start the application in development mode simply execute the `start` script:
```shell
yarn start
```
The application makes use of the environment variables described below.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| CONTRACTS_PROVIDER_PORT | `8400` | Set the port of the contracts provider application |
| UPLOAD_CONTRACTS_DIRECTORY | `concordia/packages/concordia-contracts-provider/contracts-uploads` | Set the directory where the uploaded contracts are saved |
| LOGS_PATH | `concordia/packages/concordia-contracts-provider/logs` | Set the directory where the application logs are saved |
| CORS_ALLOWED_ORIGINS | `http://127.0.0.1:7000`, `http://localhost:7000`, `https://127.0.0.1:7000`, `https://localhost:7000`, `http://127.0.0.1:4444`, `http://localhost:4444`, `https://127.0.0.1:4444`, `https://localhost:4444` | Set the list of addresses allowed by CORS* |
* the `CORS_ALLOWED_ORIGINS` env var should be a semicolon-separated string, e.g. `127.0.0.1:7000;localhost:7000`.