Skip to content

Commit

Permalink
Setup CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpegov authored Dec 8, 2023
1 parent 05d8b63 commit 04e765c
Show file tree
Hide file tree
Showing 27 changed files with 464 additions and 200 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.


#VSCode
# .vscode
# linting
.eslintcache

# dependencies
Expand All @@ -19,7 +17,7 @@
/workers
manifest.json

#static
# static
/static

# misc
Expand All @@ -34,3 +32,7 @@ yarn-error.log*

# zp config
.env

# Terraform
**/.terraform/*
*.tfstate*
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

43 changes: 43 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .vscode/easycode.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules/
dist/
vendor/
cache/
.*/
*.min.*
*.test.*
*.spec.*
*.bundle.*
*.bundle-min.*
*.*.js
*.*.ts
*.log
6 changes: 0 additions & 6 deletions Dockerfile.prod

This file was deleted.

34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,60 @@ version: 0.23.11

- [Sepolia](https://testnet.app.zeropool.network/)
- [Near](https://near.testnet.frontend.v2.zeropool.network/)
- [Waves](https://waves.testnet.console.v2.zeropool.network/) (console only)
- [Substrate](https://substrate.testnet.console.v2.zeropool.network/) (console only)
<!-- - [Waves](https://waves.testnet.console.v2.zeropool.network/) (console only) -->
<!-- - [Substrate](https://substrate.testnet.console.v2.zeropool.network/) (console only) -->

# Developement
## Developement

First of all, in the project directory create static/assets/ folder and put there respective static files from [this repo](https://github.com/zeropoolnetwork/zeropool-frontend-static.git)

Then in the project directory select the network you want to work with:

### Near:
### Near

##### `mklink .env .env.near` - Windows command prompt as admin
##### `> mklink .env .env.near` - using Windows command prompt as admin

##### `ln -s .env.near .env` - Linux
##### `> ln -s .env.near .env` - using Bash terminal

### Sepolia:
### Sepolia

##### `mklink .env .env.sepolia` - Windows command prompt as admin
##### `> mklink .env .env.sepolia` - using Windows command prompt as admin

##### `ln -s .env.sepolia .env` - Linux
##### `> ln -s .env.sepolia .env` - using Bash terminal

After that you can run the following commands:

## `yarn start`
### `> yarn start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

## `yarn test:debug`
### `> yarn test:debug`

Launches the test runner in the interactive watch mode.

## `yarn test:debug [part_of_the_file_name]`
### `> yarn test:debug [part_of_the_file_name]`

Launches the test runner in the interactive watch mode for the specified file(-s).

## `yarn test`
### `> yarn test`

Build the test coverage report.

## `yarn coverage`
### `> yarn coverage`

Runs local server to show test coverage report.

## Known issues
### <b>Known issues</b>

### `yarn start` builds the app with outdated dependencies

`rm -rf node_modules/.cache/` and then `yarn start` again
If it doesn't help, try to remove `node_modules` folder and run `yarn install` again.

## Deployment

1. `yarn publish[:dev/:test/:release]` - publishes docker container with built application to the registry
28 changes: 28 additions & 0 deletions _compose.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a auto-generated file. Do not edit!

services:
wallet:
image: antonpegov/zeropool-frontend:${VERSION}
container_name: wallet-${NETWORK_NAME}
restart: always
environment:
- REACT_APP_TOKEN=${TOKEN_NAME}
- REACT_APP_NETWORK=${NETWORK}
- REACT_APP_NETWORK_NAME=${NETWORK_NAME}
- REACT_APP_NETWORK_FAUCET=${FAUCET}
- REACT_APP_RPC_URL=${RPC_HOST}
- REACT_APP_RELAYER_URL=${RELAYER}
- REACT_APP_TOKEN_ADDRESS=${TOKEN}
- REACT_APP_CONTRACT_ADDRESS=${CONTRACT}
- REACT_APP_PUBLIC_URL=/
- REACT_APP_TRANSACTION_URL=${TRANSACTION}
- VIRTUAL_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_HOST=${VIRTUAL_HOST}
- [email protected]
volumes:
- /root/params:/usr/share/nginx/html/assets

networks:
default:
external: true
name: zeropool-testnet
58 changes: 58 additions & 0 deletions _main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 3.0.1"
}
}
}

provider "docker" {
host = "ssh://zp.dev"
}

locals {
// List of environments and related IP's
envs = {
dev = "45.131.67.82",
test = "45.131.67.83",
prod = "45.131.67.84",
}
compose = base64encode(templatefile("${path.module}/_compose.yml.tmpl", {
// Take value from environment variable VIRTUAL_HOST and change it's 'ENV' part to value from environment variable ENV
VIRTUAL_HOST = replace(var.VIRTUAL_HOST, "ENV", var.ENV),
NETWORK_NAME = var.NETWORK_NAME,
TRANSACTION = var.TRANSACTION,
TOKEN_NAME = var.TOKEN_NAME,
CONTRACT = var.CONTRACT,
RPC_HOST = var.RPC_HOST,
VERSION = var.VERSION,
NETWORK = var.NETWORK,
RELAYER = var.RELAYER,
FAUCET = var.FAUCET,
TOKEN = var.TOKEN,
}))
}

resource "null_resource" "this" {
provisioner "remote-exec" {
inline = [
"set -e",
"mkdir -p ~/wallet",
"docker compose -f ~/wallet/docker-compose-${var.NETWORK}.yml down || true",
"rm -f ~/wallet/docker-compose-${var.NETWORK}.yml",
"sudo bash -c 'echo ${local.compose} | base64 --decode > ~/wallet/docker-compose-${var.NETWORK}.yml'",
"docker network create zeropool-testnet || true",
"docker compose -f ~/wallet/docker-compose-${var.NETWORK}.yml pull",
"docker compose -f ~/wallet/docker-compose-${var.NETWORK}.yml up -d",
]

connection {
type = "ssh"
user = "root" # Replace with your SSH username
private_key = file("~/.ssh/zeropool") # Specify your private key path
host = local.envs[var.ENV] # Replace with your instance's IP or DNS
timeout = "2m" # Set a timeout to wait for the SSH connection
}
}
}
24 changes: 24 additions & 0 deletions _sepolia.tf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e

if [ -z "$1" ]; then
echo "No environment supplied"
exit 1
fi

if [ -z "$2" ]; then
echo "No version supplied"
fi

echo "Terraforming $2 on $1 environment"

case "$1" in
prod|dev|test)
;;
*)
echo "Invalid environment: $1. It should be one of: prod, dev, test."
exit 1
;;
esac

terraform apply -auto-approve -replace="null_resource.this" -var-file='_sepolia.tfvars' -var="VERSION=$2" -var="ENV=$1"
12 changes: 12 additions & 0 deletions _sepolia.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
RPC_HOST = "https://sepolia.rpc.zeropool.network"
VIRTUAL_HOST = "sepolia.testnet.frontend.ENV.v2.zeropool.network"

NETWORK_NAME = "Sepolia" # TODO: rename to "sepolia"
TOKEN_NAME = "eth"
NETWORK = "ethereum"

TOKEN = "0x25004028Dd2743FF487454eAB2216d3495667189"
FAUCET = "https://sepoliafaucet.com"
RELAYER = "https://sepolia.testnet.relayer.v2.zeropool.network"
CONTRACT = "0xEcbD5fabA99139B2cA25f19B568fF74991a01eD3"
TRANSACTION = "https://sepolia.etherscan.io/tx/{{hash}}"
60 changes: 60 additions & 0 deletions _vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

variable "RPC_HOST" {
type = string
default = "https://sepolia.rpc.zeropool.network"
}

variable "VIRTUAL_HOST" {
type = string
default = "sepolia.testnet.frontend.ENV.v2.zeropool.network"
}

variable "NETWORK_NAME" {
type = string
default = "sepolia"
}

variable "TOKEN_NAME" {
type = string
default = "eth"
}

variable "NETWORK" {
type = string
default = "ethereum"
}

variable "TOKEN" {
type = string
default = "0x25004028Dd2743FF487454eAB2216d3495667189"
}

variable "FAUCET" {
type = string
default = "https://sepoliafaucet.com"
}

variable "RELAYER" {
type = string
default = "https://sepolia.testnet.relayer.v2.zeropool.network"
}

variable "CONTRACT" {
type = string
default = "0xEcbD5fabA99139B2cA25f19B568fF74991a01eD3"
}

variable "TRANSACTION" {
type = string
default = "https://sepolia.etherscan.io/tx/{{hash}}"
}

variable "ENV" {
type = string
default = "dev"
}

variable "VERSION" {
type = string
default = "antonpegov/zeropool-frontend:latest"
}
Loading

0 comments on commit 04e765c

Please sign in to comment.