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

Env var renamings #1168

Merged
merged 13 commits into from
Jun 1, 2022
2 changes: 1 addition & 1 deletion .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
GITHUB_HEAD_REF: ${{ github.head_ref}}
GITHUB_PR_NUMBER: ${{ github.event.number}}
WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }}
WEBHOOK_REF: ${{ secrets.WEBHOOK_REF }}
WEBHOOK_REF: ${{ secrets.WEBHOOK_REF_2 }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions api/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ORGANIZATION=KfW
ORGANIZATION_VAULT_SECRET=secret
RPC_HOST=127.0.0.1
RPC_PORT=8000
RPC_PASSWORD=s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j
MULTICHAIN_RPC_HOST=127.0.0.1
MULTICHAIN_RPC_PORT=8000
MULTICHAIN_RPC_PASSWORD=s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j
PORT=8080
ROOT_SECRET=root-secret
API_PORT=8080
Expand Down
10 changes: 5 additions & 5 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
| PORT | no | 8080 | The port used to expose the API for your installation. <br/>Example: If you run TruBudget locally and set API_PORT to `8080`, you can reach the API via `localhost:8080/api`. |
| PRETTY_PRINT | no | false | Decides whether the logs printed by the API are pretty printed or not. Pretty printed logs are easier to read while non-pretty printed logs are easier to store and use e.g. in the ELK (Elasticsearch-Logstash-Kabana) stack. |
| ROOT_SECRET | no | [random] | The root secret is the password for the root user. If you start with an empty blockchain, the root user is needed to add other users, approve new nodes,.. If you don't set a value via the environment variable, the API generates one randomly and prints it to the console <br/>**Caution:** If you want to run TruBudget in production, make sure to set a secure root secret. |
| RPC_HOST | no | localhost | The IP address of the blockchain (not multichain daemon,but they are usally the same) you want to connect to. |
| BACKUP_API_PORT | no | 8085 | The Port of the blockchain (not multichain daemon,but they are usally the same) you want to connect to. |
| RPC_USER | no | multichainrpc | The user used to connect to the multichain daemon. |
| RPC_PASSWORD | no | [hardcoded] | Password used by the API to connect to the blockchain. The password is set by the origin node upon start. Every beta node needs to use the same RPC password in order to be able to connect to the blockchain. <br/>**Hint:** Although the RPC_PASSWORD is not required it is highly recommended to set an own secure one |
| RPC_PORT | no | 8000 | The port used to expose the multichain daemon of your Trubudget blockchain installation(bc). The port used to connect to the multichain daemon(api). This will be used internally for the communication between the API and the multichain daemon. |
| MULTICHAIN_RPC_HOST | no | localhost | The IP address of the blockchain (not multichain daemon,but they are usally the same) you want to connect to. |
| BLOCKCHAIN_PORT | no | 8085 | The Port of the blockchain (not multichain daemon,but they are usally the same) you want to connect to. |
| MULTICHAIN_RPC_USER | no | multichainrpc | The user used to connect to the multichain daemon. |
| MULTICHAIN_RPC_PASSWORD | no | [hardcoded] | Password used by the API to connect to the blockchain. The password is set by the origin node upon start. Every beta node needs to use the same RPC password in order to be able to connect to the blockchain. <br/>**Hint:** Although the MULTICHAIN_RPC_PASSWORD is not required it is highly recommended to set an own secure one |
| MULTICHAIN_RPC_PORT | no | 8000 | The port used to expose the multichain daemon of your Trubudget blockchain installation(bc). The port used to connect to the multichain daemon(api). This will be used internally for the communication between the API and the multichain daemon. |
| SWAGGER_BASEPATH `deprecated` | no | / | This variable was used to choose which environment (prod or test) is used for testing the requests. The variable is deprecated now, as the Swagger documentation can be used for the prod and test environment separately. |
| JWT_SECRET | no | [random] | A string that is used to sign JWT which are created by the authenticate endpoint of the api |
| DOCUMENT_FEATURE_ENABLED | no | false | If true, all uploaded documents are stored using trubudget's storage-service. If false, the document feature of TruBudget is disabled, and trying to upload a document will result in an error. |
Expand Down
6 changes: 3 additions & 3 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ services:
build:
context: ../blockchain
environment:
RPC_PORT: ${RPC_PORT}
MULTICHAIN_RPC_PORT: ${MULTICHAIN_RPC_PORT}
ORGANIZATION: ${ORGANIZATION}
RPC_PASSWORD: ${RPC_PASSWORD}
MULTICHAIN_RPC_PASSWORD: ${MULTICHAIN_RPC_PASSWORD}
ports:
- "8000:${RPC_PORT}"
- "8000:${MULTICHAIN_RPC_PORT}"
- "8085:8085"
22 changes: 11 additions & 11 deletions api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ interface ProcessEnvVars {
ORGANIZATION_VAULT_SECRET: string;
PORT: string;
ROOT_SECRET: string;
RPC_HOST: string;
RPC_PORT: string;
RPC_USER: string;
RPC_PASSWORD: string;
BACKUP_API_PORT: string;
MULTICHAIN_RPC_HOST: string;
MULTICHAIN_RPC_PORT: string;
MULTICHAIN_RPC_USER: string;
MULTICHAIN_RPC_PASSWORD: string;
BLOCKCHAIN_PORT: string;
JWT_SECRET: string;
CI_COMMIT_SHA: string;
BUILDTIMESTAMP: string;
Expand Down Expand Up @@ -77,16 +77,16 @@ export const config: Config = {
rootSecret: process.env.ROOT_SECRET || randomString(32),
// RPC is the mutlichain daemon
rpc: {
host: process.env.RPC_HOST || "localhost",
port: Number(process.env.RPC_PORT) || 8000,
user: process.env.RPC_USER || "multichainrpc",
password: process.env.RPC_PASSWORD || "s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j",
host: process.env.MULTICHAIN_RPC_HOST || "localhost",
port: Number(process.env.MULTICHAIN_RPC_PORT) || 8000,
user: process.env.MULTICHAIN_RPC_USER || "multichainrpc",
password: process.env.MULTICHAIN_RPC_PASSWORD || "s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j",
},
// Blockchain is the blockchain component of Trubudget
// It serves e.g. backup or version endpoints
blockchain: {
host: process.env.RPC_HOST || "localhost",
port: Number(process.env.BACKUP_API_PORT) || 8085,
host: process.env.MULTICHAIN_RPC_HOST || "localhost",
port: Number(process.env.BLOCKCHAIN_PORT) || 8085,
},
jwtSecret: process.env.JWT_SECRET || randomString(32),
version: process.env.npm_package_version || "",
Expand Down
10 changes: 5 additions & 5 deletions api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ const {
* Initialize the components:
*/

const multichainHost = process.env.RPC_HOST || "localhost";
const backupApiPort = process.env.BACKUP_API_PORT || "8085";
const multichainHost = process.env.MULTICHAIN_RPC_HOST || "localhost";
const backupApiPort = process.env.BLOCKCHAIN_PORT || "8085";

const rpcSettings: ConnectionSettings = {
protocol: "http",
host: multichainHost,
port: parseInt(process.env.RPC_PORT || "8000", 10),
username: process.env.RPC_USER || "multichainrpc",
password: process.env.RPC_PASSWORD || "s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j",
port: parseInt(process.env.MULTICHAIN_RPC_PORT || "8000", 10),
username: process.env.MULTICHAIN_RPC_USER || "multichainrpc",
password: process.env.MULTICHAIN_RPC_PASSWORD || "s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j",
};

logger.info(
Expand Down
6 changes: 3 additions & 3 deletions blockchain/.env_example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RPC_PORT=8000
RPC_PASSWORD=s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j
MULTICHAIN_RPC_PORT=8000
MULTICHAIN_RPC_PASSWORD=s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j
ORGANIZATION=KfW
EMAIL_HOST=localhost
EMAIL_PORT=8889
MULTICHAIN_FEED=ENABLED
MULTICHAIN_FEED_ENABLED=true
6 changes: 3 additions & 3 deletions blockchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Depending on the Trubudget setup environment variables
| P2P_PORT | no | 7447 | The port on which the node you want to connect to has exposed the blockchain. |
| PRETTY_PRINT | no | false | Decides whether the logs printed by the API are pretty printed or not. Pretty printed logs are easier to read while non-pretty printed logs are easier to store and use e.g. in the ELK (Elasticsearch-Logstash-Kabana) stack. |
| RPC_ALLOW_IP | no | 0.0.0.0/0 | It refers to an allowed IP address range, given either by IP or CIDR notation. 0.0.0.0/0 will allow access from anywhere. |
| RPC_USER | no | multichainrpc | The user used to connect to the multichain daemon. |
| RPC_PASSWORD | no | [hardcoded] | Password used by the API to connect to the blockchain. The password is set by the origin node upon start. Every beta node needs to use the same RPC password in order to be able to connect to the blockchain. <br/>**Hint:** Although the RPC_PASSWORD is not required it is highly recommended to set an own secure one |
| RPC_PORT | no | 8000 | The port used to expose the multichain daemon of your Trubudget blockchain installation(bc). The port used to connect to the multichain daemon(api). This will be used internally for the communication between the API and the multichain daemon. |
| MULTICHAIN_RPC_USER | no | multichainrpc | The user used to connect to the multichain daemon. |
| MULTICHAIN_RPC_PASSWORD | no | [hardcoded] | Password used by the API to connect to the blockchain. The password is set by the origin node upon start. Every beta node needs to use the same RPC password in order to be able to connect to the blockchain. <br/>**Hint:** Although the MULTICHAIN_RPC_PASSWORD is not required it is highly recommended to set an own secure one |
| MULTICHAIN_RPC_PORT | no | 8000 | The port used to expose the multichain daemon of your Trubudget blockchain installation(bc). The port used to connect to the multichain daemon(api). This will be used internally for the communication between the API and the multichain daemon. |
| ACCESS_CONTROL_ALLOW_ORIGIN | no | "\*" | This environment variable is needed for the feature "Export to Excel". Since the export service uses CORS, the domain by which it can be called needs to be set. Setting this value to `"*"` means that it can be called from any domain. Read more about this topic [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). |
| CI_COMMIT_SHA | no | | The /version endpoint returns this variable as `commit` property |
| BUILDTIMESTAMP | no | | The /version endpoint returns this variable as `buildTimeStamp` property |
Expand Down
4 changes: 2 additions & 2 deletions blockchain/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ services:
blockchain:
build: .
environment:
RPC_PORT: ${RPC_PORT}
RPC_PASSWORD: ${RPC_PASSWORD}
MULTICHAIN_RPC_PORT: ${MULTICHAIN_RPC_PORT}
MULTICHAIN_RPC_PASSWORD: ${MULTICHAIN_RPC_PASSWORD}
ORGANIZATION: ${ORGANIZATION}
EMAIL_HOST: ${EMAIL_HOST}
EMAIL_PORT: ${EMAIL_PORT}
Expand Down
18 changes: 9 additions & 9 deletions blockchain/src/createChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const configureChain = (
isAlpha,
chainName,
multichainDir,
RPC_PORT,
RPC_USER,
RPC_PASSWORD,
MULTICHAIN_RPC_PORT,
MULTICHAIN_RPC_USER,
MULTICHAIN_RPC_PASSWORD,
RPC_ALLOW_IP,
isMultichainFeedEnabled,
) => {
Expand All @@ -35,18 +35,18 @@ const configureChain = (
if (isMultichainFeedEnabled) {
log.info("Multichain feed is enabled");
shell.exec(`cat <<EOF >"${multichainDir}/multichain.conf"
rpcport=${RPC_PORT}
rpcuser=${RPC_USER}
rpcpassword=${RPC_PASSWORD}
rpcport=${MULTICHAIN_RPC_PORT}
rpcuser=${MULTICHAIN_RPC_USER}
rpcpassword=${MULTICHAIN_RPC_PASSWORD}
rpcallowip=${RPC_ALLOW_IP}
walletnotifynew=${__dirname}/multichain-feed/multichain-feed %j
EOF
`);
} else {
shell.exec(`cat <<EOF >"${multichainDir}/multichain.conf"
rpcport=${RPC_PORT}
rpcuser=${RPC_USER}
rpcpassword=${RPC_PASSWORD}
rpcport=${MULTICHAIN_RPC_PORT}
rpcuser=${MULTICHAIN_RPC_USER}
rpcpassword=${MULTICHAIN_RPC_PASSWORD}
rpcallowip=${RPC_ALLOW_IP}
EOF
`);
Expand Down
16 changes: 8 additions & 8 deletions blockchain/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const port = process.env.PORT || 8085;

const ORGANIZATION = process.env.ORGANIZATION || "MyOrga";
const CHAINNAME = "TrubudgetChain";
const RPC_PORT = process.env.RPC_PORT || 8000;
const RPC_USER = process.env.RPC_USER || "multichainrpc";
const RPC_PASSWORD =
process.env.RPC_PASSWORD || "s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j";
const MULTICHAIN_RPC_PORT = process.env.MULTICHAIN_RPC_PORT || 8000;
const MULTICHAIN_RPC_USER = process.env.MULTICHAIN_RPC_USER || "multichainrpc";
const MULTICHAIN_RPC_PASSWORD =
process.env.MULTICHAIN_RPC_PASSWORD || "s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j";
const RPC_ALLOW_IP = process.env.RPC_ALLOW_IP || "0.0.0.0/0";
const CERT_PATH = process.env.CERT_PATH || undefined;
const CERT_CA_PATH = process.env.CERT_CA_PATH || undefined;
Expand Down Expand Up @@ -127,9 +127,9 @@ configureChain(
isAlpha,
CHAINNAME,
multichainDir,
RPC_PORT,
RPC_USER,
RPC_PASSWORD,
MULTICHAIN_RPC_PORT,
MULTICHAIN_RPC_USER,
MULTICHAIN_RPC_PASSWORD,
RPC_ALLOW_IP,
multichainFeedEnabled,
);
Expand Down Expand Up @@ -306,7 +306,7 @@ app.post("/chain", async (req, res) => {
const chainConfig = yaml.safeLoad(
fs.readFileSync(chainConfigPath, "utf8"),
);
let correctConfig = chainConfig.includes(RPC_PASSWORD);
let correctConfig = chainConfig.includes(MULTICHAIN_RPC_PASSWORD);

if (config.hasOwnProperty("Organisation")) {
const correctOrg = config.Organisation === ORGANIZATION;
Expand Down
10 changes: 5 additions & 5 deletions docker-compose/testing/run-all-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ services:
api:
image: trubudget/api:${TAG}
environment:
RPC_HOST: alpha
RPC_PORT: ${RPC_PORT}
RPC_PASSWORD: ${RPC_PASSWORD}
MULTICHAIN_RPC_HOST: alpha
MULTICHAIN_RPC_PORT: ${MULTICHAIN_RPC_PORT}
MULTICHAIN_RPC_PASSWORD: ${MULTICHAIN_RPC_PASSWORD}
PORT: ${API_PORT}
ORGANIZATION: KfW
ROOT_SECRET: ${ROOT_SECRET}
Expand All @@ -26,8 +26,8 @@ services:
alpha:
image: trubudget/blockchain:${TAG}
environment:
RPC_PORT: ${RPC_PORT}
RPC_PASSWORD: ${RPC_PASSWORD}
MULTICHAIN_RPC_PORT: ${MULTICHAIN_RPC_PORT}
MULTICHAIN_RPC_PASSWORD: ${MULTICHAIN_RPC_PASSWORD}
ORGANIZATION: KfW
volumes:
- /alphaVolume:/root/.multichain
Expand Down
6 changes: 3 additions & 3 deletions docs/developer/developer-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ cd ../api

```bash
ORGANIZATION=ACMECorp
RPC_HOST=127.0.0.1
RPC_PORT=8000
MULTICHAIN_RPC_HOST=127.0.0.1
MULTICHAIN_RPC_PORT=8000
PORT=8080
ROOT_SECRET='root-secret'
ORGANIZATION_VAULT_SECRET="secret"
RPC_PASSWORD=s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j
MULTICHAIN_RPC_PASSWORD=s750SiJnj50yIrmwxPnEdSzpfGlTAHzhaUwgqKeb0G1j
```

2. Install node-modules
Expand Down
Loading