Tezos link is a gateway to access to the Tezos network aiming to improve developer experience when developing Tezos dApps.
- Project organization
- Run services locally on the machine
- Build all services
- Tests all services
- Frontend
- Services
- Infrastructure
- Documentation
- References
The repository is currently following this organization:
.
├── api # api documentation
├── build # packaging
├── cmd # mains
├── config # config parsers
├── data # config and migrations
├── infra # infrastructure
├── internal # services
├── test # test-specific files
└── web # frontend
└── public
└── docs # usage documentation
Blockchain nodes are mocked up for development environment the be as lightweight as possible.
Docker
docker-compose
Yarn
(setup with 1.22.0)Golang
(setup with 1.13)GNU Make
(setup with 3.81)Node.js
(setup with 11.14.0)
To run services locally on the machine, you will need to run those commands :
$> make deps
$> make build-docker
$> make run-dev
It will run:
tezos-link_proxy
tezos-link_proxy-carthagenet
tezos-link_api
mockserver/mockserver:mockserver-5.9.0
(mocking a blockchain node)postgres:9.6
The only endpoint served by the blockchain mock is:
curl -X PUT localhost:8001/v1/<YOUR_PROJECT_ID>/mockserver/status
Golang
(setup with 1.13)GNU Make
(setup with 3.81)
For integrations tests only:
Docker
docker-compose
yarn
To run the unit tests
, you can use the command
$> make unit-test
To run integration tests
locally, you will need to run following commands :
# We build docker images and run them
$> make build-docker & make run
# We run integration tests...
$> make integration-test
# And we clean the environment when we are done
$> docker-compose down
GNU Make
(setup with 3.81)Golang
(setup with 1.13)Yarn
(setup with 1.22.0)Node.js
(setup with 11.14.0)
To build your project, you need first to install dependencies
:
$> make deps
After, you can run the build
with
$> make build
Yarn
(setup with 1.22.0)Node.js
(setup with 11.14.0)
To build the frontend, you need first to install dependencies
:
$> make deps
To run the frontend, execute:
$> cd web && yarn start-local
To run the frontend, execute:
$> make build-frontend
You will need AWS credentials setup on your machine, see AWS Credentials
To run the frontend, execute:
$> make deploy-frontend
REST API to manage projects and get project's metrics.
PostgreSQL
(setup with 9.6)
DATABASE_URL
(default:postgres:5432
)DATABASE_USERNAME
(default:user
)DATABASE_PASSWORD
(default:pass
)DATABASE_TABLE
(default:tezoslink
)DATABASE_ADDITIONAL_PARAMETER
(default:sslmode=disable
)SERVER_HOST
(default:localhost
)SERVER_PORT
(default:8000
)
- HTTP proxy in front of the nodes
- In-memory (LRU) cache
PostgreSQL
(setup with 9.6)
DATABASE_URL
(default:postgres:5432
)DATABASE_USERNAME
(default:user
)DATABASE_PASSWORD
(default:pass
)DATABASE_TABLE
(default:tezoslink
)DATABASE_ADDITIONAL_PARAMETER
(default:sslmode=disable
)ARCHIVE_NODES_URL
(default:node
)TEZOS_ARCHIVE_PORT
(default:1090
)ROLLING_NODES_URL
(default:node
)TEZOS_ROLLING_PORT
(default:1090
)SERVER_PORT
(default:8001
)
Lambda function scheduled with a Cloudwatch Rule
cronjob, connect to a node with SSH and trigger a snapshot export.
Individual deployment of the lambda is possible for testing and development purpose.
You will need AWS credentials setup on your machine, see AWS Credentials
It will build, send to the S3 bucket and update snapshot lambda code:
$> make build-unix
$> make deploy-snapshot-lambda
To execute the lambda, run:
aws lambda invoke --region=eu-west-1 --function-name=snapshot --log Tail output.txt | grep "LogResult"| awk -F'"' '{print $4}' | base64 --decode
Lambda function scheduled with a Cloudwatch Rule
cronjob, connect to a node with SSH and trigger a metrics clean.
Individual deployment of the lambda is possible for testing and development purpose.
You will need AWS credentials setup on your machine, see AWS Credentials
It will build, send to the S3 bucket and update metrics-cleaner lambda code:
$> make build-unix
$> make deploy-metrics-cleaner-lambda
To execute the lambda, run:
aws lambda invoke --region=eu-west-1 --function-name=metrics --log Tail output.txt | grep "LogResult"| awk -F'"' '{print $4}' | base64 --decode
These environment variables are set in infra/dev.tfvars
.
NODE_USER
(default:ec2-user
)S3_REGION
(default:eu-west-1
)S3_BUCKET
(default:tzlink-snapshot-lambda-dev
)S3_LAMBDA_KEY
(default:snapshot_lambda_key
)
Terraform
(version == 0.12.20)Terragrunt
(version == 0.21.4)
We recommend to install
tf-env
to manage easily your terraform environments.
All the files related to the infrastructure are based on the infra
folder.
First, you will need to update the configuration (if needed). To do this, you will find common.tfvars
and <env>.tfvars
in the folder infra/terragrunt
.
Currently, database password is encrypted inside the file
vaulted.tfvars
. To see it content, you will need ansible-vault and a passphrase to decrypt it with the commandansible-vault decrypt vaulted.tfvars
.This will be changed soon with AWS Secret Manager.
When they are updated, we will use Terragrunt to deploy our infrastructure by running:
# To check if all is OK
$> terragrunt plan-all
# To apply the change
$> terragrunt apply-all
If you want to apply a specific part of the infrastructure (ex: 00_network
), you can run
$> cd infra/terragrunt/00_network
# To check if all is OK
$> terragrunt plan
# To apply the change
$> terragrunt apply
The documentation usage is located at web/public/docs
.
It contains the various Markdown files served by the application at /documentation
.
This repo took some ideas & code from: