Skip to content

Commit

Permalink
Merge pull request #267 from d-rec/develop
Browse files Browse the repository at this point in the history
Dev to Stage Push
  • Loading branch information
Aish1990 authored May 23, 2024
2 parents 9f1a323 + 3e4f268 commit 39a19e1
Show file tree
Hide file tree
Showing 50 changed files with 2,132 additions and 1,959 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# EditorConfig is awesome: https://EditorConfig.org

[*]
# Ensure consistent file encoding in UNIX style
charset = utf-8
end_of_line = lf
24 changes: 24 additions & 0 deletions .github/workflows/check-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check Docs

on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
prettier:
name: Lint prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v4
with:
node-version: lts/gallium

- name: Run Prettier on Docs
working-directory: docs
run: npx prettier . --check
40 changes: 40 additions & 0 deletions .github/workflows/check-generic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generic checks to ease collaboration:
# - consistent file encoding in UNIX style
# - whitespaces in all purposes files like markdown, yaml, etc
name: Check Generic

on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
editorconfig-checker:
name: Run editorconfig-checker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run editorconfig-checker
run: docker run --rm --volume=$PWD:/check mstruebing/editorconfig-checker

markdownlint:
name: Run markdownlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run markdownlint-cli2
uses: DavidAnson/markdownlint-cli2-action@v13

yamllint:
name: Run yamllint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run yamllint
run: yamllint .
14 changes: 14 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Disable some built-in rules
config:
line-length: false
no-inline-html: false
first-line-h1: false
code-fence-style:
style: backtick

# Define glob expressions to use (only valid at root)
globs:
- "**/*.md"

# Ignore files that are not part of version control
gitignore: true
24 changes: 10 additions & 14 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"printWidth": 100,
"singleQuote": true,
"useTabs": false,
"semi": true,
"tabWidth": 4,
"trailingComma": "none",
"overrides": [
{
"files": "*.{yaml,yml}",
"options": {
"tabWidth": 2
}
}
]
"singleQuote": true,
"trailingComma": "all",
"overrides": [
{
"files": "*.{yaml,yml}",
"options": {
"singleQuote": false
}
}
]
}
18 changes: 18 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends: default

ignore-from-file:
- .gitignore
- .yamllintignore

rules:
document-start: disable
indentation:
spaces: 2
line-length: disable
quoted-strings:
quote-type: double
required: only-when-needed
allow-quoted-quotes: true
check-keys: true
truthy:
check-keys: false
1 change: 1 addition & 0 deletions .yamllintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
66 changes: 39 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,118 +28,130 @@
</p>

---

Repository for Origin DREC project

## Local environment setup of Ubuntu

Install `wsl`,`ubuntu-18.04` in command prompt running as administrator:
```

```sh
wsl --install
wsl --install --distribution Ubuntu-18.04
```

Install `Influx-Client`:
```
Install `Influx-Client`:

```sh
sudo apt install influx client
sudo apt update
```

Restart the Ubuntu terminal once, after installation done.
Clone and Install `nvm`:
```

```sh
sudo wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install 14.19.1
```

Install `rush`, `pnpm` if you don't have it:
```

```sh
npm i -g @microsoft/rush
npm i -g pnpm
```

Create and change directory:
```

```sh
mkdir drec
cd drec
```

Clone repository:
It should be cloned in both local and Ubuntu environment.
```

```sh
git clone https://github.com/drec/drec-origin.git
chmod -R 777 drec-origin/
```

Copy `.env.example` to `.env` and adjust `.env` with your environment specific parameters.
```

```sh
cp .env.example .env
```

Start Postgres, Redis, InfluxDB instance

Please create and start your Postgres, Redis and InfluxDB by running below command in our root directory, after that anytime you can manage this images through your docker desktop installed on your system.
```

```sh
docker-compose up --build
```

Create Postgres DB table
```

```sh
psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE origin"
```

Create Default Admin:

Please update below environment variables under defauld admin credential with the values that you wanted to create as default admin user.

```
```sh
ADMIN_EMAIL
ADMIN_PASSWORD
```


Install dependencies, Run db migrations:
```

```sh
rush install
rush build
```

Run API project
```

```sh
rush start:dev
```

You may also want to drop local databases with
```

```sh
rush drop
```

## How to use

Go inside integrators-scripts folder
Create a .env, copy everything from .env.example and change the necessary variables depending on the environment
```

```sh
npm i
npm run start
```

## Metamask Setup:
## Metamask Setup

1. The metamask extension required to add in default browser before generating certificate. Create login
2. When selecting netweok option choose the add manual network, use below values to create network manually
a. Network Name - It's depend on user (ex., Volta, Voltatest)
b. New RPC URL - https://volta-rpc.energyweb.org
c. ChainID - 73799
d. Symbol - VT
e. Block Explorer URL - https://volta-rpc.energyweb.org
1. The metamask extension required to add in default browser before generating certificate. Create login
2. When selecting netweok option choose the add manual network, use below values to create network manually
a. Network Name - It's depend on user (ex., Volta, Voltatest)
b. New RPC URL - <https://volta-rpc.energyweb.org>
c. ChainID - 73799
d. Symbol - VT
e. Block Explorer URL - <https://volta-rpc.energyweb.org>
3. Update your blockchain address and mnemonic as the variables `DREC_BLOCKCHAIN_ADDRESS` and `MNEMONIC` in our .env file
4. Add balance to your wallet using this link https://voltafaucet.energyweb.org/ by providing your blockchain address of your metamask
4. Add balance to your wallet using this link <https://voltafaucet.energyweb.org/> by providing your blockchain address of your metamask
5. To get the issuer private key, go to Account details, click on the show private key button, there you will find the your Issuer private key. Add this key in your environment file as `ISSUER_PRIVATE_KEY`


Before running the script, make sure:

1. You have updated the DREC_BACKEND_URL in .env with local - also update the username and password for each integrator
2. Post generated devices to Server - Bulk Devices
3. You updated DREC_USERNAME & DREC_PASSWORD with the Owner credentials based on the integrator (Okra, BBOX, Engie etc.)
4. The methods in index.js should run independently. After each step, comment the completed step, uncomment the next step and restart the server
5. You can also use the docker desktop installed in local system which will be used to up the docker containers manually
5. You can also use the docker desktop installed in local system which will be used to up the docker containers manually
2 changes: 1 addition & 1 deletion apps/drec-api/.lintstagedrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"prettier --write --config-precedence file-override './src/**/*'",
"eslint --fix"
]
}
}
4 changes: 0 additions & 4 deletions apps/drec-api/.prettierrc

This file was deleted.

44 changes: 22 additions & 22 deletions apps/drec-api/buildspec.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
version: 0.2
env:
parameter-store:
docker_username: /powertrust/docker/username
docker_password: /powertrust/docker/password
phases:
install:
# runtime-versions:
# nodejs: 18
# docker: 18
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- chmod +x ./kubectl
- curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64
- chmod +x ./aws-iam-authenticator
- export PATH=$PWD/:$PATH
build:
commands:
- chmod +x ./buildscript.sh
- ./buildscript.sh
version: 0.2
env:
parameter-store:
docker_username: /powertrust/docker/username
docker_password: /powertrust/docker/password
phases:
install:
# runtime-versions:
# nodejs: 18
# docker: 18
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- chmod +x ./kubectl
- curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.9/aws-iam-authenticator_0.5.9_linux_amd64
- chmod +x ./aws-iam-authenticator
- export PATH=$PWD/:$PATH
build:
commands:
- chmod +x ./buildscript.sh
- ./buildscript.sh
16 changes: 8 additions & 8 deletions apps/drec-api/drec-api-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ spec:
app.kubernetes.io/name: drec-api
spec:
containers:
- image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-api:{{BUILD_NUMBER}}
imagePullPolicy: Always
name: drec-api
envFrom:
- secretRef:
name: drec-dev-env
ports:
- containerPort: 3040
- image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-api:{{BUILD_NUMBER}}
imagePullPolicy: Always
name: drec-api
envFrom:
- secretRef:
name: drec-dev-env
ports:
- containerPort: 3040
---
apiVersion: v1
kind: Service
Expand Down
16 changes: 8 additions & 8 deletions apps/drec-api/drec-api-migrate-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ spec:
app.kubernetes.io/name: drec-api-migrate
spec:
containers:
- image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-api-migrate:{{BUILD_NUMBER}}
imagePullPolicy: Always
name: drec-api-migrate
envFrom:
- secretRef:
name: drec-dev-env
ports:
- containerPort: 3040
- image: 895706603967.dkr.ecr.eu-west-1.amazonaws.com/drec-api-migrate:{{BUILD_NUMBER}}
imagePullPolicy: Always
name: drec-api-migrate
envFrom:
- secretRef:
name: drec-dev-env
ports:
- containerPort: 3040
---
apiVersion: v1
kind: Service
Expand Down
Loading

0 comments on commit 39a19e1

Please sign in to comment.