Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/multiple entry/docker file2 #1433

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions config/config.placeholder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
network: 'DAPP_CONFIG'
metaChainShardId: 4294967295
api:
public: true
publicPort: 3001
private: true
privatePort: 4001
websocket: true
cron:
cacheWarmer: true
fastWarm: true
queueWorker: true
elasticUpdater: false
flags:
useRequestCaching: true
useKeepAliveAgent: true
useTracing: false
useRequestLogging: false
useVmQueryTracing: false
processNfts: true
collectionPropertiesFromGateway: false
features:
eventsNotifier:
enabled: false
port: 5674
url: 'amqp://guest:[email protected]:5673'
exchange: 'all_events'
queue: 'api-process-logs-and-events'
guestCaching:
enabled: false
hitsThreshold: 100
ttl: 12
transactionPool:
enabled: false
transactionPoolWarmer:
enabled: false
cronExpression: '*/5 * * * * *'
ttlInSeconds: 60
updateCollectionExtraDetails:
enabled: false
updateAccountExtraDetails:
enabled: false
marketplace:
enabled: false
serviceUrl: 'https://devnet-nfts-graph.multiversx.com/graphql'
exchange:
enabled: false
serviceUrl: 'https://devnet-graph.xexchange.com/graphql'
dataApi:
enabled: false
serviceUrl: 'https://devnet-data-api.multiversx.com'
assetsFetch:
enabled: true
assetesUrl: 'https://tools.multiversx.com/assets-cdn'
auth:
enabled: false
maxExpirySeconds: 86400
acceptedOrigins:
- ''
admins:
- ''
jwtSecret: ''
stakingV4:
enabled: false
cronExpression: '*/5 * * * * *'
activationEpoch: 1043
nodeEpochsLeft:
enabled: false
transactionProcessor:
enabled: false
maxLookBehind: 100
transactionCompleted:
enabled: false
maxLookBehind: 100
logLevel: 'Error'
transactionBatch:
enabled: true
maxLookBehind: 100
statusChecker:
enabled: false
thresholds:
tokens: 500
nodes: 3000
providers: 10
tokenSupplyCount: 20
tokenAssets: 20
tokenAccounts: 500
tokenTransactions: 500
nodeValidators: 300
nftScamInfo:
enabled: false
processNfts:
enabled: false
nftQueueName: 'api-process-nfts'
deadLetterQueueName: 'api-process-nfts-dlq'
tps:
enabled: false
maxLookBehindNonces: 100
nodesFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
tokensFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
providersFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
image:
width: 600
height: 600
type: 'png'
aws:
s3KeyId: ''
s3Secret: ''
s3Bucket: 'devnet-media.elrond.com'
s3Region: ''
urls:
self: 'https://devnet-api.multiversx.com'
elastic:
- 'ELASTICSEARCH_URL'
gateway:
- 'GATEWAY_URL'
verifier: 'https://play-api.multiversx.com'
redis: 'REDIS_IP'
rabbitmq: 'RABBITMQ_URL'
providers: 'PROVIDERS_URL'
delegation: 'DELEGATION_URL'
media: 'https://devnet-media.elrond.com'
nftThumbnails: 'https://devnet-media.elrond.com/nfts/thumbnail'
tmp: '/tmp'
ipfs: 'https://ipfs.io/ipfs'
socket: 'SOCKET_URL'
maiarId: 'https://devnet-id-api.multiversx.com'
indexer:
type: 'elastic'
maxPagination: 10000
database:
enabled: false
url: 'mongodb://127.0.0.1:27017/api?authSource=admin'
type: 'mysql'
host: 'localhost'
port: 3306
username: 'root'
password: 'root'
database: 'api'
caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
contracts:
esdt: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u'
auction: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l'
staking: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqllls0lczs7'
delegationManager: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqylllslmq6y6'
delegation: 'erd1qqqqqqqqqqqqqpgq97wezxw6l7lgg7k9rxvycrz66vn92ksh2tssxwf7ep'
metabonding: 'erd1qqqqqqqqqqqqqpgqkg7we73j769ew5we4yyx7uyvnn0nefqgd8ssm6vjc2'
inflation:
- 1952123
- 1746637
- 1541150
- 1335663
- 1130177
- 924690
- 719203
nftProcess:
parallelism: 1
maxRetries: 3
17 changes: 17 additions & 0 deletions config/dapp.config.placeholder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "PLACEHOLDER_DAPP_id",
"name": "PLACEHOLDER_DAPP_name",
"egldLabel": "PLACEHOLDER_DAPP_egldLabel",
"decimals": "4",
"egldDenomination": "18",
"gasPerDataByte": "1500",
"apiTimeout": "4000",
"walletConnectDeepLink": "https://maiar.page.link/?apn=com.multiversx.maiar.wallet&isi=1519405832&ibi=com.multiversx.maiar.wallet&link=https://maiar.com/",
"walletConnectBridgeAddresses": [
"https://bridge.walletconnect.org"
],
"walletAddress": "PLACEHOLDER_DAPP_walletAddress",
"apiAddress": "PLACEHOLDER_DAPP_apiAddress",
"explorerAddress": "PLACEHOLDER_DAPP_explorerAddress",
"chainId": "PLACEHOLDER_DAPP_chainId"
}
96 changes: 54 additions & 42 deletions entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
#!/bin/sh
# ENV VARIABLES
# MVX_ENV - defines what config to copy (default devnet)
# ELASTICSEARCH_URL - defines custom elasticsearch url - eg https://devnet-index.multiversx.com
# GATEWAY_URL - defines custom gateway url - eg https://devnet-gateway.multiversx.com
# REDIS_IP - defines redis ip - default 127.0.0.1

# CHECK IF ENV IS DEFINED
if [ -n "$MVX_ENV" ] && [ "$MVX_ENV" = "devnet" ]; then
# Copy config file
cp ./config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml

if [ $? -eq 0 ]; then
echo "Config file copied successfully from config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml"
else
echo "Failed to copy the file."
fi

else
cp ./config/config.devnet.yaml /app/dist/config/config.yaml

if [ $? -eq 0 ]; then
echo "Default config file copied successfully from config/config.devnet.yaml /app/dist/config/config.yaml"
else
echo "Failed to copy the file."
fi
fi

# Replaces urls if defined
if [ -n "$REDIS_IP" ]; then
echo "Redis IP defined: ${REDIS_IP}, replacing in config"
sed -i "s|redis: '127.0.0.1'|redis: '${REDIS_IP}'|g" /app/dist/config/config.yaml
fi

if [ -n "$ELASTICSEARCH_URL" ]; then
echo "Elasticsearch url defined: ${ELASTICSEARCH_URL}, replacing in config"
sed -i "/^ elastic:/!b; n; s|.*| - '${ELASTICSEARCH_URL}'|" /app/dist/config/config.yaml
fi

if [ -n "$GATEWAY_URL" ]; then
echo "Gateway url defined: ${GATEWAY_URL}, replacing in config"
sed -i "/^ gateway:/!b; n; s|.*| - '${GATEWAY_URL}'|" /app/dist/config/config.yaml
fi

# MVX_ENV=devnet
# DAPP_CONFIG=devnet
# REDIS_IP=127.0.0.1
# ELASTICSEARCH_URL=https://devnet-index.multiversx.com
# GATEWAY_URL=https://devnet-gateway.multiversx.com
# RABBITMQ_URL=amqp://127.0.0.1:5672
# PROVIDERS_URL=https://devnet-delegation-api.multiversx.com/providers
# DELEGATION_URL=https://devnet-delegation-api.multiversx.com
# SOCKET_URL=devnet-socket-api.multiversx.com
# PLACEHOLDER_DAPP_id=devnet
# PLACEHOLDER_DAPP_name=Devnet
# PLACEHOLDER_DAPP_egldLabel=xEGLD
# PLACEHOLDER_DAPP_walletAddress=https://devnet-wallet.multiversx.com
# PLACEHOLDER_DAPP_apiAddress=https://devnet-api.multiversx.com
# PLACEHOLDER_DAPP_explorerAddress=http://devnet-explorer.multiversx.com
# PLACEHOLDER_DAPP_chainId=D

env_vars_with_defaults="MVX_ENV=devnet DAPP_CONFIG=devnet REDIS_IP=127.0.0.1 ELASTICSEARCH_URL=https://devnet-index.multiversx.com GATEWAY_URL=https://devnet-gateway.multiversx.com RABBITMQ_URL=amqp://127.0.0.1:5672 PROVIDERS_URL=https://devnet-delegation-api.multiversx.com/providers DELEGATION_URL=https://devnet-delegation-api.multiversx.com SOCKET_URL=devnet-socket-api.multiversx.com PLACEHOLDER_DAPP_id=devnet PLACEHOLDER_DAPP_name=Devnet PLACEHOLDER_DAPP_egldLabel=xEGLD PLACEHOLDER_DAPP_walletAddress=https://devnet-wallet.multiversx.com PLACEHOLDER_DAPP_apiAddress=https://devnet-api.multiversx.com PLACEHOLDER_DAPP_explorerAddress=http://devnet-explorer.multiversx.com PLACEHOLDER_DAPP_chainId=D"

replace_placeholder() {
local var_name=$1
local var_value=$2

case $var_name in
PLACEHOLDER_DAPP*)
echo "Var ${var_name} defined, replacing ${var_value} in /app/config/dapp.config.placeholder.json"
sed -i "s|${var_name}|${var_value}|g" /app/config/dapp.config.placeholder.json
;;
*)
echo "Var ${var_name} defined, replacing ${var_value} in /app/dist/config/config.yaml"
sed -i "s|${var_name}|${var_value}|g" /app/dist/config/config.yaml
;;
esac

}

# Loop through each environment variable
for entry in $env_vars_with_defaults; do
# Split the entry into name and value
var_name=$(echo $entry | cut -d= -f1)
default_value=$(echo $entry | cut -d= -f2)

# Use the environment variable value if defined; otherwise, use the default
eval "value=\${$var_name:-$default_value}"

cp ./config/config.placeholder.yaml /app/dist/config/config.yaml
if [ $? -eq 0 ]; then
echo "Config file copied successfully from config/config.placeholder.yaml /app/dist/config/config.yaml"
fi

# Execute the function with the variable name and value
replace_placeholder "$var_name" "$value"

done

exec /usr/local/bin/node dist/src/main.js
Loading