Skip to content

Commit

Permalink
make domain configurable (notional-labs#402)
Browse files Browse the repository at this point in the history
`$USE_DOMAIN_NAME`
  • Loading branch information
baabeetaa authored Jun 19, 2023
1 parent 74f1fbc commit e2e0a2e
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 30 deletions.
2 changes: 1 addition & 1 deletion admin/cronjob_get_snapshot_size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TMP_STATUS_FILE="$TMP_DIR/snapshot_sizes.json"

service_str=""
for service_name in $RPC_SERVICES; do
file_size=$(curl -Ls "https://snapshot.notional.ventures/$service_name/chain.json" |jq -r '.file_size')
file_size=$(curl -Ls "https://snapshot.${USE_DOMAIN_NAME}/$service_name/chain.json" |jq -r '.file_size')
if [[ ! -z "$service_str" ]]; then
service_str="$service_str,"$'\n'
fi
Expand Down
2 changes: 2 additions & 0 deletions admin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ git clone --single-branch --branch main https://github.com/notional-labs/cosmosi
cat <<EOT >> $HOME/cosmosia/env.sh
CHAIN_REGISTRY_INI_URL=$CHAIN_REGISTRY_INI_URL
USE_SNAPSHOT_PROXY_URL=$USE_SNAPSHOT_PROXY_URL
USE_DOMAIN_NAME=$USE_DOMAIN_NAME
COSMOSIA_ADMIN_NEXTAUTH_URL=$COSMOSIA_ADMIN_NEXTAUTH_URL
COSMOSIA_ADMIN_NEXTAUTH_SECRET=$COSMOSIA_ADMIN_NEXTAUTH_SECRET
COSMOSIA_ADMIN_PASSWORD=$COSMOSIA_ADMIN_PASSWORD
Expand All @@ -31,6 +32,7 @@ cd $HOME/cosmosia/admin/web
cat <<EOT >> .env.local
NEXTAUTH_URL="$COSMOSIA_ADMIN_NEXTAUTH_URL"
NEXTAUTH_SECRET="$COSMOSIA_ADMIN_NEXTAUTH_SECRET"
NEXT_PUBLIC_USE_DOMAIN_NAME="$USE_DOMAIN_NAME"
ADMIN_PASSWORD="$COSMOSIA_ADMIN_PASSWORD"
CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL"
EOT
Expand Down
1 change: 1 addition & 0 deletions admin/web/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="secret"
ADMIN_PASSWORD="admin"
NEXT_PUBLIC_USE_DOMAIN_NAME=notional.ventures
CHAIN_REGISTRY_INI_URL="https://raw.githubusercontent.com/notional-labs/cosmosia/main/data/chain_registry.ini"
14 changes: 8 additions & 6 deletions admin/web/src/pages/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ export async function getServerSideProps() {
for (let i = 0; i < chainList.length; i++) {
const chain = chainList[i];

const domain = process.env.NEXT_PUBLIC_USE_DOMAIN_NAME;

// public endpoints
const public_rpc = `https://rpc-${chain}-ia.cosmosia.notional.ventures/`;
const public_api = `https://api-${chain}-ia.cosmosia.notional.ventures/`;
const public_grpc = `grpc-${chain}-ia.cosmosia.notional.ventures:433`;
const public_rpc = `https://rpc-${chain}-ia.cosmosia.${domain}/`;
const public_api = `https://api-${chain}-ia.cosmosia.${domain}/`;
const public_grpc = `grpc-${chain}-ia.cosmosia.${domain}:433`;

// internal endpoints
const internal_rpc = `https://rpc-${chain}-${secretTokens[counter]}-ie.internalendpoints.notional.ventures`;
const internal_rpc = `https://rpc-${chain}-${secretTokens[counter]}-ie.internalendpoints.${domain}`;
counter++;
const internal_api = `https://api-${chain}-${secretTokens[counter]}-ie.internalendpoints.notional.ventures`;
const internal_api = `https://api-${chain}-${secretTokens[counter]}-ie.internalendpoints.${domain}`;
counter++;
const internal_grpc = `grpc-${chain}-${secretTokens[counter]}-ie.internalendpoints.notional.ventures:433`;
const internal_grpc = `grpc-${chain}-${secretTokens[counter]}-ie.internalendpoints.${domain}:433`;
counter++;

endpoints.push({
Expand Down
4 changes: 3 additions & 1 deletion admin/web/src/pages/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { DownOutlined, GlobalOutlined } from "@ant-design/icons";
import Link from 'next/link';
import { timeAgoFormat } from "../helper/utils";

const domain = process.env.NEXT_PUBLIC_USE_DOMAIN_NAME;

export async function getServerSideProps() {
let snapList = [];
try {
Expand Down Expand Up @@ -55,7 +57,7 @@ const SnapshotTable = (props) => {
render: (_, { Name }) => {
const chain_name = Name.slice(9); // remove snapshot_ prefix
return (
<a href={`https://snapshot.notional.ventures/${chain_name}/`} target="_blank" rel="noopener noreferrer"><GlobalOutlined /></a>
<a href={`https://snapshot.${domain}/${chain_name}/`} target="_blank" rel="noopener noreferrer"><GlobalOutlined /></a>
)
},
},
Expand Down
1 change: 1 addition & 0 deletions env.sample.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CHAIN_REGISTRY_INI_URL=https://raw.githubusercontent.com/notional-labs/cosmosia/main/data/chain_registry.ini
USE_SNAPSHOT_PROXY_URL=https://snapshot.notional.ventures/
USE_DOMAIN_NAME=notional.ventures
COSMOSIA_ADMIN_NEXTAUTH_URL=https://admin.cosmosia.notional.ventures
COSMOSIA_ADMIN_NEXTAUTH_SECRET=secret
COSMOSIA_ADMIN_PASSWORD=admin
2 changes: 1 addition & 1 deletion proxy/internal/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ http {

server {
listen 443 ssl http2;
server_name default.internalendpoints.notional.ventures;
server_name default.internalendpoints.$USE_DOMAIN_NAME;

location / {
root /usr/share/nginx/html;
Expand Down
19 changes: 10 additions & 9 deletions proxy/internal/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ EOT
source $HOME/env.sh

########################################################################################################################
# SSL for notional.ventures (fullchain.pem and privkey.pem files)
# SSL (fullchain.pem and privkey.pem files)
wget "http://tasks.web_config/config/fullchain.pem" -O /etc/nginx/fullchain.pem
wget "http://tasks.web_config/config/privkey.pem" -O /etc/nginx/privkey.pem

########################################################################################################################
# nginx

curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/internal/nginx.conf > /etc/nginx/nginx.conf
curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/internal/nginx.conf > $HOME/nginx.conf.template
cat $HOME/nginx.conf.template |envsubst '$USE_DOMAIN_NAME' > /etc/nginx/nginx.conf

# get tokens
wget "http://tasks.web_config/config/internal_proxy_secret_tokens.txt" -O $HOME/internal_proxy_secret_tokens.txt
Expand Down Expand Up @@ -77,7 +78,7 @@ for service_name in $SERVICES; do
server {
listen 80;
listen 443 ssl http2;
server_name rpc-${service_with_token}-ie.internalendpoints.notional.ventures;
server_name rpc-${service_with_token}-ie.internalendpoints.$USE_DOMAIN_NAME;
$HEADER_CORS
location ~* ^/(.*) {
$HEADER_OPTIONS
Expand All @@ -95,7 +96,7 @@ EOT
server {
listen 80;
listen 443 ssl http2;
server_name api-${service_with_token}-ie.internalendpoints.notional.ventures;
server_name api-${service_with_token}-ie.internalendpoints.$USE_DOMAIN_NAME;
$HEADER_CORS
location ~* ^/(.*) {
$HEADER_OPTIONS
Expand All @@ -113,7 +114,7 @@ EOT
server {
listen 9090 http2;
listen 443 ssl http2;
server_name grpc-${service_with_token}-ie.internalendpoints.notional.ventures;
server_name grpc-${service_with_token}-ie.internalendpoints.$USE_DOMAIN_NAME;
location / {
grpc_pass grpc://backend_grpc_${service_name};
Expand All @@ -138,7 +139,7 @@ for service_name in $SERVICES_SUBNODE; do
server {
listen 80;
listen 443 ssl http2;
server_name rpc-${service_with_token}-sub.internalendpoints.notional.ventures;
server_name rpc-${service_with_token}-sub.internalendpoints.$USE_DOMAIN_NAME;
$HEADER_CORS
location ~* ^/(.*) {
$HEADER_OPTIONS
Expand All @@ -156,7 +157,7 @@ EOT
server {
listen 80;
listen 443 ssl http2;
server_name api-${service_with_token}-sub.internalendpoints.notional.ventures;
server_name api-${service_with_token}-sub.internalendpoints.$USE_DOMAIN_NAME;
$HEADER_CORS
location ~* ^/(.*) {
$HEADER_OPTIONS
Expand All @@ -174,7 +175,7 @@ EOT
server {
listen 9090 http2;
listen 443 ssl http2;
server_name grpc-${service_with_token}-sub.internalendpoints.notional.ventures;
server_name grpc-${service_with_token}-sub.internalendpoints.$USE_DOMAIN_NAME;
location / {
grpc_pass grpc://backend_grpc_sub_${service_name};
Expand All @@ -201,7 +202,7 @@ for service_name in $SERVICES_JSONRPC; do
server {
listen 80;
listen 443 ssl http2;
server_name jsonrpc-${service_with_token}-ie.internalendpoints.notional.ventures;
server_name jsonrpc-${service_with_token}-ie.internalendpoints.$USE_DOMAIN_NAME;
$HEADER_CORS
# WS-JSON-RPC
Expand Down
6 changes: 3 additions & 3 deletions proxy/public/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ http {
server {
listen 80;
listen 443 ssl;
server_name default.cosmosia.notional.ventures;
server_name default.cosmosia.$USE_DOMAIN_NAME;
return 444;
}

server {
listen 443 ssl;
server_name admin.cosmosia.notional.ventures;
server_name admin.cosmosia.$USE_DOMAIN_NAME;

location ~* ^/(.*) {
set $target_monitor tasks.admin;
Expand All @@ -84,7 +84,7 @@ http {

server {
listen 443 ssl;
server_name grafana.cosmosia.notional.ventures;
server_name grafana.cosmosia.$USE_DOMAIN_NAME;

location ~* ^/(.*) {
proxy_http_version 1.1;
Expand Down
6 changes: 3 additions & 3 deletions proxy/public/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL"
EOT

########################################################################################################################
# SSL for notional.ventures (fullchain.pem and privkey.pem files)
# tar -xvf "/run/secrets/ssl_notional.ventures.tar.gz" -C /etc/nginx/
# SSL (fullchain.pem and privkey.pem files)
wget "http://tasks.web_config/config/fullchain.pem" -O /etc/nginx/fullchain.pem
wget "http://tasks.web_config/config/privkey.pem" -O /etc/nginx/privkey.pem

########################################################################################################################
# nginx

curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/public/nginx.conf > /etc/nginx/nginx.conf
curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/public/nginx.conf > $HOME/nginx.conf.template
cat $HOME/nginx.conf.template |envsubst '$USE_DOMAIN_NAME' > /etc/nginx/nginx.conf

# generate index.html
SERVICES=$(curl -s "$CHAIN_REGISTRY_INI_URL" |grep -E "\[.*\]" | sed 's/^\[\(.*\)\]$/\1/')
Expand Down
8 changes: 4 additions & 4 deletions proxy/static/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ http {

server {
listen 443 ssl;
server_name status.notional.ventures;
server_name status.$USE_DOMAIN_NAME;

location ~* ^/validator_healthcheck/(.*) {
set $target_validator_healthcheck tasks.validator_healthcheck;
Expand All @@ -105,7 +105,7 @@ http {

server {
listen 443 ssl;
server_name snapshot.notional.ventures;
server_name snapshot.$USE_DOMAIN_NAME;

location / {
root /usr/share/nginx/html;
Expand All @@ -117,7 +117,7 @@ http {

server {
listen 443 ssl;
server_name admin.notional.ventures;
server_name admin.$USE_DOMAIN_NAME;

location ~* ^/(.*) {
set $target_monitor tasks.admin;
Expand All @@ -127,7 +127,7 @@ http {

server {
listen 443 ssl;
server_name grafana.notional.ventures;
server_name grafana.$USE_DOMAIN_NAME;

location ~* ^/(.*) {
proxy_http_version 1.1;
Expand Down
5 changes: 3 additions & 2 deletions proxy/static/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ pacman -Syu --noconfirm
pacman -S --noconfirm base-devel wget dnsutils nginx cronie screen

########################################################################################################################
# SSL for notional.ventures (fullchain.pem and privkey.pem files)
# SSL (fullchain.pem and privkey.pem files)
wget "http://tasks.web_config/config/fullchain.pem" -O /etc/nginx/fullchain.pem
wget "http://tasks.web_config/config/privkey.pem" -O /etc/nginx/privkey.pem

########################################################################################################################
# nginx
curl -s "https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/static/nginx.conf" > /etc/nginx/nginx.conf
curl -s "https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/static/nginx.conf" > $HOME/nginx.conf.template
cat $HOME/nginx.conf.template |envsubst '$USE_DOMAIN_NAME' > /etc/nginx/nginx.conf

# generate index.html
curl -s "$CHAIN_REGISTRY_INI_URL" > $HOME/chain_registry.ini
Expand Down

0 comments on commit e2e0a2e

Please sign in to comment.