feat: add support for .env

This commit is contained in:
Václav Pavlín 2023-11-13 12:55:46 +01:00
parent 62cc2c1f10
commit 20f91f4242
No known key found for this signature in database
GPG Key ID: B378FB31BB6D89A5
6 changed files with 22 additions and 13 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/<key>
ETH_TESTNET_KEY=012345privatekey
RLN_RELAY_CRED_PASSWORD="my_secure_keystore_password"

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
keystore keystore
postgresql postgresql
rln_tree rln_tree
.env

View File

@ -17,7 +17,7 @@ You need:
``` ```
export ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/YOUR_INFURA_KEY export ETH_CLIENT_ADDRESS=wss://sepolia.infura.io/ws/v3/YOUR_INFURA_KEY
export ETH_TESTNET_KEY=REPLACE_BY_YOUR_KEY export ETH_TESTNET_KEY=REPLACE_BY_YOUR_KEY
export KEYSTORE_PASSWORD=PICK_A_PASSWORD export RLN_RELAY_CRED_PASSWORD=PICK_A_PASSWORD
``` ```
**🔑 1. Register RLN membership** **🔑 1. Register RLN membership**

View File

@ -47,7 +47,7 @@ services:
environment: environment:
DOMAIN: ${DOMAIN} DOMAIN: ${DOMAIN}
NODEKEY: ${NODEKEY} NODEKEY: ${NODEKEY}
KEYSTORE_PASSWORD: ${KEYSTORE_PASSWORD} KEYSTORE_PASSWORD: "${KEYSTORE_PASSWORD}"
ETH_CLIENT_ADDRESS: *eth_client_address ETH_CLIENT_ADDRESS: *eth_client_address
EXTRA_ARGS: ${EXTRA_ARGS} EXTRA_ARGS: ${EXTRA_ARGS}
<<: <<:
@ -119,8 +119,8 @@ services:
- ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z - ./postgres_cfg/db.sql:/docker-entrypoint-initdb.d/db.sql:Z
- ${PG_DATA_DIR:-./postgresql}:/var/lib/postgresql/data:Z - ${PG_DATA_DIR:-./postgresql}:/var/lib/postgresql/data:Z
command: postgres -c config_file=/etc/postgresql/postgresql.conf command: postgres -c config_file=/etc/postgresql/postgresql.conf
ports: ports: []
- 127.0.0.1:5432:5432 # - 127.0.0.1:5432:5432
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -d db_prod"] test: ["CMD-SHELL", "pg_isready -d db_prod"]
interval: 30s interval: 30s

View File

@ -1,17 +1,24 @@
#!/bin/sh #!/bin/sh
if test -f ./keystore/keystore.json; then if test -f $(pwd)/keystore/keystore.json; then
echo "keystore/keystore.json alredy exists. Use it instead of creating a new one." echo "keystore/keystore.json alredy exists. Use it instead of creating a new one."
echo "Exiting" echo "Exiting"
exit 1 exit 1
fi fi
if test -f .env; then
echo "Using .env file"
. $(pwd)/.env
fi
# TODO: Set nwaku release when ready instead of quay # TODO: Set nwaku release when ready instead of quay
docker run -v $(pwd)/keystore:/keystore/:Z wakuorg/nwaku:v0.21.3 generateRlnKeystore \ docker run -v $(pwd)/keystore:/keystore/:Z wakuorg/nwaku:v0.21.3 generateRlnKeystore \
--rln-relay-eth-client-address=${ETH_CLIENT_ADDRESS} \ --rln-relay-eth-client-address=${ETH_CLIENT_ADDRESS} \
--rln-relay-eth-private-key=${ETH_TESTNET_KEY} \ --rln-relay-eth-private-key=${ETH_TESTNET_KEY} \
--rln-relay-eth-contract-address=0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4 \ --rln-relay-eth-contract-address=0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4 \
--rln-relay-cred-path=/keystore/keystore.json \ --rln-relay-cred-path=/keystore/keystore.json \
--rln-relay-cred-password=${KEYSTORE_PASSWORD} \ --rln-relay-cred-password="'"${RLN_RELAY_CRED_PASSWORD}"'" \
--execute --execute

View File

@ -46,12 +46,12 @@ if [ -n "${NODEKEY}" ]; then
NODEKEY=--nodekey=${NODEKEY} NODEKEY=--nodekey=${NODEKEY}
fi fi
if [ -n "${RLN_RELAY_CRED_PATH}" ]; then
RLN_RELAY_CRED_PATH=--rln-relay-cred-path=${RLN_RELAY_CRED_PATH} RLN_RELAY_CRED_PATH=--rln-relay-cred-path=${RLN_RELAY_CRED_PATH:-/keystore/keystore.json}
fi
if [ -n "${RLN_RELAY_CRED_PASSWORD}" ]; then if [ -n "${RLN_RELAY_CRED_PASSWORD}" ]; then
RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password=${RLN_RELAY_CRED_PASSWORD} RLN_RELAY_CRED_PASSWORD=--rln-relay-cred-password="'"${RLN_RELAY_CRED_PASSWORD}"'"
fi fi
exec /usr/bin/wakunode\ exec /usr/bin/wakunode\
@ -95,8 +95,6 @@ exec /usr/bin/wakunode\
--rln-relay-eth-contract-address="${RLN_RELAY_CONTRACT_ADDRESS}"\ --rln-relay-eth-contract-address="${RLN_RELAY_CONTRACT_ADDRESS}"\
--rln-relay-eth-client-address="${ETH_CLIENT_ADDRESS}"\ --rln-relay-eth-client-address="${ETH_CLIENT_ADDRESS}"\
--rln-relay-tree-path="/etc/rln_tree"\ --rln-relay-tree-path="/etc/rln_tree"\
--rln-relay-cred-password="${KEYSTORE_PASSWORD}"\
--rln-relay-cred-path="/keystore/keystore.json"\
${RLN_RELAY_CRED_PATH}\ ${RLN_RELAY_CRED_PATH}\
${RLN_RELAY_CRED_PASSWORD}\ ${RLN_RELAY_CRED_PASSWORD}\
${DNS_WSS_CMD}\ ${DNS_WSS_CMD}\