From 52dab8c987a738a29cb68da8e40354d3597e9cf2 Mon Sep 17 00:00:00 2001 From: "adrien.boulay" Date: Thu, 3 Sep 2020 20:30:11 +0200 Subject: [PATCH] Update docs/README.md and add file path --- docs/How_to_run_locally.md | 36 ++++++++++++++++++++++ docs/How_to_run_on_AWS.md | 42 +++++++++++++++++++++++++ docs/Project_organization.md | 20 ++++++++++++ docs/README.md | 59 +++++++++++------------------------- docs/References.md | 9 ++++++ docs/services/Proxy.md | 21 +++++++++++++ 6 files changed, 146 insertions(+), 41 deletions(-) create mode 100644 docs/How_to_run_locally.md create mode 100644 docs/How_to_run_on_AWS.md create mode 100644 docs/Project_organization.md create mode 100644 docs/References.md create mode 100644 docs/services/Proxy.md diff --git a/docs/How_to_run_locally.md b/docs/How_to_run_locally.md new file mode 100644 index 0000000..da1c99c --- /dev/null +++ b/docs/How_to_run_locally.md @@ -0,0 +1,36 @@ +# Local deployment of the service + +> Blockchain nodes are mocked up for development environment the be as lightweight as possible. + +## Requirements + +- `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) + +## How to + +To run services locally on the machine, you will need to run those commands : + +```bash +$> 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: + +```bash +curl -X PUT localhost:8001/v1//mockserver/status +``` \ No newline at end of file diff --git a/docs/How_to_run_on_AWS.md b/docs/How_to_run_on_AWS.md new file mode 100644 index 0000000..171328d --- /dev/null +++ b/docs/How_to_run_on_AWS.md @@ -0,0 +1,42 @@ +# How to deploy + +< TODO : To improve> + +## Requirements + +- `Terraform` (version == 0.12.20) +- `Terragrunt` (version == 0.21.4) + +> We recommend to install `tf-env` to manage easily your terraform environments. + +## Deployment process + +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 `.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 command `ansible-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: + +```bash +# 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 + +```bash +$> cd infra/terragrunt/00_network + +# To check if all is OK +$> terragrunt plan + +# To apply the change +$> terragrunt apply +``` \ No newline at end of file diff --git a/docs/Project_organization.md b/docs/Project_organization.md new file mode 100644 index 0000000..6ad9e7a --- /dev/null +++ b/docs/Project_organization.md @@ -0,0 +1,20 @@ +# Project organization + +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 +``` + +TODO : to write \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index a403f8b..bf915e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,40 +2,24 @@ ## Table of Contents -- [Project organization](#project-organization) -- [Run services locally on the machine](#run-services-locally-on-the-machine) -- [Build all services](#build-all-services) -- [Tests all services](#tests-all-services) -- [Frontend](#frontend) -- [Services](#services) - - [API](#api) - - [Proxy](#proxy) - - [Snapshot exporter](#snapshot-exporter) -- [Infrastructure](#infrastructure) - - [Architecture](#architecture) - - [Requirements](#requirements) - - [How To Deploy](#how-to-deploy) -- [Documentation](#documentation) -- [References](#references) - -## Project Organization - -The repository is currently following this organization: +1 - [Project organization](./Project_organization.md) -``` -. -├── 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 -``` +2 - [Architecture](./Architecture.md) + +3 - [Run the project on the machine](./How_to_run_locally.md) + +4 - [Deploy the project on a cloud provider](./How_to_deploy_on_AWS.md) + +5 - [Services](./services) + - [API](./services/API.md) + - [Proxy](./services/Proxy.md) + - [Frontend](./services/Frontend.md) + +6 - [Lambdas](./lambdas) + - [Snapshot exporter](./lambdas/Snapshot_Exporter.md) + - [Metrics cleaner](./lambdas/Metrics_Cleaner.md) + +A - [References](./References) ## Run services locally on the machine with mockup blockchain node @@ -227,11 +211,4 @@ $> terragrunt plan # To apply the change $> terragrunt apply -``` - -## References - -This repo took some ideas & code from: - -- https://github.com/tezexInfo/TezProxy -- https://github.com/AymericBethencourt/serverless-mern-stack/ \ No newline at end of file +``` \ No newline at end of file diff --git a/docs/References.md b/docs/References.md new file mode 100644 index 0000000..d88827b --- /dev/null +++ b/docs/References.md @@ -0,0 +1,9 @@ +# References + +Libraries & tools: +- https://github.com/AymericBethencourt/serverless-mern-stack/ +- https://registry.terraform.io/providers/hashicorp/aws/latest/docs +- https://terragrunt.gruntwork.io/ + +Ideas: +- https://github.com/tezexInfo/TezProxy \ No newline at end of file diff --git a/docs/services/Proxy.md b/docs/services/Proxy.md new file mode 100644 index 0000000..568949e --- /dev/null +++ b/docs/services/Proxy.md @@ -0,0 +1,21 @@ +# Proxy + +- HTTP proxy in front of the nodes +- In-memory (LRU) cache + +## Dependencies + +- `PostgreSQL` (setup with 9.6) + +## Environment variables + +- `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`) \ No newline at end of file