Skip to content

Commit

Permalink
Add generate env scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cuonghx committed Nov 13, 2024
1 parent d9fee5f commit eb9cf3b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.DS_Store
.idea/
data/
container_env_files/
!container_env_files_templates/.env
9 changes: 9 additions & 0 deletions container_env_files_templates/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
REVERSE_PROXY_PORT=8000

CFG_VERSION=staging
CGW_VERSION=staging
TXS_VERSION=staging
UI_VERSION=dev
EVENTS_VERSION=staging

RPC_NODE_URL={RPC_NODE_URL}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ CGW_AUTH_TOKEN=your_privileged_endpoints_token

# CSRF protection
# See https://docs.djangoproject.com/en/dev/ref/settings/#csrf-trusted-origins
CSRF_TRUSTED_ORIGINS="http://localhost:8000"
CSRF_TRUSTED_ORIGINS={CONFIG_DOMAIN}

MEDIA_URL = "http://localhost:8000/cfg/media/"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ REDIS_URL=redis://txs-redis:6379/0
CELERY_BROKER_URL=amqp://guest:guest@txs-rabbitmq/
DJANGO_ALLOWED_HOSTS="*"
FORCE_SCRIPT_NAME=/txs/
CSRF_TRUSTED_ORIGINS="http://localhost:8000"
CSRF_TRUSTED_ORIGINS={CONFIG_DOMAIN}
EVENTS_QUEUE_URL=amqp://general-rabbitmq:5672
EVENTS_QUEUE_ASYNC_CONNECTION=True
EVENTS_QUEUE_EXCHANGE_NAME="safe-transaction-service-events"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Required variables ###
NEXT_PUBLIC_INFURA_TOKEN=
NEXT_PUBLIC_GATEWAY_URL_PRODUCTION=http://localhost:8000/cgw
NEXT_PUBLIC_GATEWAY_URL_PRODUCTION=http://{CONFIG_DOMAIN}/cgw

# infura token used by Safe Apps
NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN=
Expand Down
33 changes: 33 additions & 0 deletions scripts/setup_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Create the directory if it does not exist
mkdir -p container_env_files

# Check for required environment variables
if [ -z "${CONFIG_DOMAIN}" ]
then
echo CONFIG_DOMAIN env is missing
exit 1
fi

if [ -z "${RPC_NODE_URL}" ]
then
echo RPC_NODE_URL env is missing
exit 1
fi

# Generate the environment files using `sed`
sed "s|{RPC_NODE_URL}|$RPC_NODE_URL|g;" $1 ./container_env_files_templates/.env > .env

sed "s|{CONFIG_DOMAIN}|$CONFIG_DOMAIN|g;" $1 ./container_env_files_templates/cfg.env > ./container_env_files/cfg.env

cp ./container_env_files_templates/cgw.env ./container_env_files/cgw.env

cp ./container_env_files_templates/events.env ./container_env_files/events.env

sed "s|{CONFIG_DOMAIN}|$CONFIG_DOMAIN|g;" $1 ./container_env_files_templates/txs.env > ./container_env_files/txs.env

sed "s|{CONFIG_DOMAIN}|$CONFIG_DOMAIN|g;" $1 ./container_env_files_templates/ui.env > ./container_env_files/ui.env



0 comments on commit eb9cf3b

Please sign in to comment.