|
| 1 | +# snapshot-hub |
| 2 | + |
| 3 | +REST API for snapshot frontend. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +``` |
| 8 | +npm install |
| 9 | +``` |
| 10 | + |
| 11 | +## Start server |
| 12 | + |
| 13 | +``` |
| 14 | +npm start |
| 15 | +``` |
| 16 | + |
| 17 | +### Environment variables |
| 18 | + |
| 19 | +- `PINATA_API_KEY` - API key of [pinata](https://pinata.cloud/). |
| 20 | +- `PINATA_SECRET_API_KEY` - SECRET key of [pinata](https://pinata.cloud/). |
| 21 | +- `NODE_ENV` - development, test or production |
| 22 | +- `POSTGRES_DB` # DataBase name. |
| 23 | +- `POSTGRES_PASSWORD` # DataBase password. |
| 24 | +- `POSTGRES_USER` # DataBase username. |
| 25 | +- `POSTGRES_HOST` # DataBase host for example (127.0.0.1) for production build use 'postgres'. |
| 26 | + |
| 27 | +## Setup database |
| 28 | + |
| 29 | +- sequelize config - `lib/config/sequelize.ts` |
| 30 | + |
| 31 | +## Build docker container |
| 32 | + |
| 33 | +```bash |
| 34 | +$ docker-compose build # run building. |
| 35 | +$ docker-compose up -d # runing. |
| 36 | +``` |
| 37 | + |
| 38 | +## Snapshot Spaces Commit |
| 39 | + |
| 40 | +https://github.com/Zilliqa/snapshot-spaces/commit/238e87aad231351a51727b06208ab407f0de1dcc |
| 41 | + |
| 42 | +20220216 |
| 43 | + |
| 44 | +## Deploying applications with z |
| 45 | + |
| 46 | +`z` is the one-stop shop for the Zilliqa provisioning and deployment operations. To deploy applications with z ensure the `z` |
| 47 | +binary is installed in your operative system PATH environment variable. For more details about `z` please refer to the [documentation](https://github.com/Zilliqa/devops/blob/main/docs/z2.md). |
| 48 | + |
| 49 | +## Deploying applications to staging |
| 50 | + |
| 51 | +To deploy the staging environment we need to clone the devops repository and execute `z` from there: |
| 52 | + |
| 53 | +```sh |
| 54 | +git clone https://github.com/Zilliqa/devops.git |
| 55 | +cd devops |
| 56 | +source setenv |
| 57 | +``` |
| 58 | + |
| 59 | +### Set the following environment variables |
| 60 | + |
| 61 | +- `Z_ENV` to the path in which your `z.yaml` resides. |
| 62 | +- `ZQ_USER` to your username (the bit before `@` in your email address) |
| 63 | +- `GITHUB_PAT` (if you are deploying staging or production apps) to a classic PAT with all the repo permissions ticked. |
| 64 | + |
| 65 | +for example: |
| 66 | + |
| 67 | +```sh |
| 68 | +export Z_ENV=`pwd`/infra/live/gcp/non-production/prj-d-staging/z_ase1.yaml |
| 69 | +export ZQ_USER=<user_id>@zilliqa.com |
| 70 | +export GITHUB_PAT=<GITHUB_PAT> |
| 71 | +``` |
| 72 | + |
| 73 | +### Login to Google Cloud |
| 74 | + |
| 75 | +```sh |
| 76 | +z login |
| 77 | +``` |
| 78 | + |
| 79 | +### Add the application to the staging `z.yaml` file. Skip this step if it is an existing application |
| 80 | + |
| 81 | +1. Create a branch: |
| 82 | + |
| 83 | + ```sh |
| 84 | + git checkout -b users/<username>/add_governance-api_to_staging_cluster |
| 85 | + ``` |
| 86 | + |
| 87 | +2. In the file `infra/live/gcp/non-production/prj-d-staging/z_ase1.yaml` add the following: |
| 88 | + |
| 89 | + - in `apps` stanza add: |
| 90 | + |
| 91 | + ```yaml |
| 92 | + clusters: |
| 93 | + staging: |
| 94 | + apps: |
| 95 | + governance-api: |
| 96 | + repo: https://github.com/Zilliqa/zilliqa-developer |
| 97 | + path: products/governance-api/cd/overlays/staging |
| 98 | + track: staging |
| 99 | + type: kustomize |
| 100 | + ``` |
| 101 | +
|
| 102 | + - in `subdomains` stanza add: |
| 103 | + |
| 104 | + ```yaml |
| 105 | + infrastructure: |
| 106 | + dns: |
| 107 | + vars: |
| 108 | + subdomains: |
| 109 | + governance-api: {} |
| 110 | + ``` |
| 111 | + |
| 112 | +3. Push the changes |
| 113 | + |
| 114 | + ```sh |
| 115 | + git add . |
| 116 | + git commit -m "Add governance-api to staging cluster" |
| 117 | + git push origin users/<username>/add_governance-api_to_staging_cluster |
| 118 | + ``` |
| 119 | + |
| 120 | +4. Open a Pull Request to the main branch |
| 121 | + |
| 122 | +5. Apply the changes |
| 123 | + |
| 124 | + ```sh |
| 125 | + z plan |
| 126 | + z apply |
| 127 | + ``` |
| 128 | + |
| 129 | +### Deploy the application |
| 130 | + |
| 131 | +```sh |
| 132 | +z app sync --cache-dir=.cache governance-api |
| 133 | +``` |
| 134 | + |
| 135 | +Verify your application is running correct from the staging URL and with `kubectl` commands (if required). |
| 136 | + |
| 137 | +## Deploying applications to production |
| 138 | + |
| 139 | +To deploy the production environment we need to clone the devops repository and execute `z` from there: |
| 140 | + |
| 141 | +```sh |
| 142 | +git clone https://github.com/Zilliqa/devops.git |
| 143 | +cd devops |
| 144 | +source setenv |
| 145 | +``` |
| 146 | + |
| 147 | +### Set the following environment variables |
| 148 | + |
| 149 | +- `Z_ENV` to the path in which your `z.yaml` resides. |
| 150 | +- `ZQ_USER` to your username (the bit before `@` in your email address) |
| 151 | +- `GITHUB_PAT` (if you are deploying staging or production apps) to a classic PAT with all the repo permissions ticked. |
| 152 | + |
| 153 | +for example: |
| 154 | + |
| 155 | +```sh |
| 156 | +export Z_ENV=`pwd`/infra/live/gcp/production/prj-p-prod-apps/z_ase1.yaml |
| 157 | +export ZQ_USER=<user_id>@zilliqa.com |
| 158 | +export GITHUB_PAT=<GITHUB_PAT> |
| 159 | +``` |
| 160 | + |
| 161 | +### Login to Google Cloud |
| 162 | + |
| 163 | +```sh |
| 164 | +z login |
| 165 | +``` |
| 166 | + |
| 167 | +### Add the application to the production `z.yaml` file. Skip this step if it is an existing application |
| 168 | + |
| 169 | +1. Create a branch: |
| 170 | + |
| 171 | + ```sh |
| 172 | + git checkout -b users/<username>/add_governance-api_to_production_cluster |
| 173 | + ``` |
| 174 | + |
| 175 | +2. In the file `infra/live/gcp/production/prj-p-prod-apps/z_ase1.yaml` add the following: |
| 176 | + |
| 177 | + - in `apps` stanza add: |
| 178 | + |
| 179 | + ```yaml |
| 180 | + clusters: |
| 181 | + production: |
| 182 | + apps: |
| 183 | + governance-api: |
| 184 | + repo: https://github.com/Zilliqa/zilliqa-developer |
| 185 | + path: products/governance-api/cd/overlays/production |
| 186 | + track: production |
| 187 | + type: kustomize |
| 188 | + ``` |
| 189 | +
|
| 190 | + - in `subdomains` stanza add: |
| 191 | + |
| 192 | + ```yaml |
| 193 | + infrastructure: |
| 194 | + dns: |
| 195 | + vars: |
| 196 | + subdomains: |
| 197 | + governance-api: {} |
| 198 | + ``` |
| 199 | + |
| 200 | +3. Push the changes |
| 201 | + |
| 202 | + ```sh |
| 203 | + git add . |
| 204 | + git commit -m "Add governance-api to production cluster" |
| 205 | + git push origin users/<username>/add_governance-api_to_production_cluster |
| 206 | + ``` |
| 207 | + |
| 208 | +4. Open a Pull Request to the main branch |
| 209 | + |
| 210 | +5. Apply the changes |
| 211 | + |
| 212 | + ```sh |
| 213 | + z plan |
| 214 | + z apply |
| 215 | + ``` |
| 216 | + |
| 217 | +### Deploy the application |
| 218 | + |
| 219 | +```sh |
| 220 | +z app sync --cache-dir=.cache governance-api |
| 221 | +``` |
| 222 | + |
| 223 | +Verify your application is running correct from the production URL and with `kubectl` commands (if required). |
0 commit comments