Skip to content

Commit

Permalink
Create two env files (#1775)
Browse files Browse the repository at this point in the history
* Create two env files

* Add root var

* Add base back to compose

* Add base values to root .env

---------

Co-authored-by: Michael Peels <michaelpeels@Michael-Peels.local>
  • Loading branch information
mpeels and Michael Peels authored Sep 6, 2024
1 parent a88f3d5 commit f436f5d
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 10 deletions.
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ yarn-error.log*

# local environment set up
application-local.yml
local.env
local.env
.env

# cdc-sandbox
dist/

nifi/repo
nifi/nifi_conf/conf/flow.json.gz
archive/
NEDSSDev/
cdc-sandbox/.env
7 changes: 0 additions & 7 deletions cdc-sandbox/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions cdc-sandbox/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh
set -e
BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

source $BASE/check_env.sh

if [ -z "$DATABASE_PASSWORD" ] || [ -z "$NIFI_PASSWORD" ] || [ -z "$KEYCLOAK_ADMIN_PASSWORD" ] || [ -z "$TOKEN_SECRET" ] || [ -z "$PARAMETER_SECRET" ]
then
Expand Down
8 changes: 7 additions & 1 deletion cdc-sandbox/build_classic.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/sh
set -e

BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

source $BASE/check_env.sh

if [ -z "$DATABASE_PASSWORD" ]
then
echo "DATABASE_PASSWORD is required"
exit 1
else
echo "Building NBS classic with:"
echo "DATABASE_PASSWORD=$DATABASE_PASSWORD"
fi

BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

CLASSIC_PATH=$BASE/nbs-classic/builder/NEDSSDev
CLASSIC_VERSION=NBS_6.0.16
Expand Down
11 changes: 10 additions & 1 deletion cdc-sandbox/build_modernized.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/sh
set -e
BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

source $BASE/check_env.sh

if [ -z "$DATABASE_PASSWORD" ] || [ -z "$NIFI_PASSWORD" ] || [ -z "$KEYCLOAK_ADMIN_PASSWORD" ] || [ -z "$TOKEN_SECRET" ] || [ -z "$PARAMETER_SECRET" ]
then
echo "DATABASE_PASSWORD, NIFI_PASSWORD, KEYCLOAK_ADMIN_PASSWORD, TOKEN_SECRET are required"
exit 1
else
echo "Building modernized services with:"
echo "DATABASE_PASSWORD: $DATABASE_PASSWORD"
echo "NIFI_PASSWORD: $NIFI_PASSWORD"
echo "KEYCLOAK_ADMIN_PASSWORD: $KEYCLOAK_ADMIN_PASSWORD"
echo "PARAMETER_SECRET: $PARAMETER_SECRET"
echo "TOKEN_SECRET: $TOKEN_SECRET"
fi

BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

# Start ES and the proxy
echo "Starting elasticsearch reverse-proxy"
Expand Down
32 changes: 32 additions & 0 deletions cdc-sandbox/check_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
set -e
BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
ROOT="$BASE/.."

# Checks for the presence of a `.env` file in the scripts directory.
# If one is found, load the values, otherwise create the .env with placeholders for expected values
if [ -f $BASE/.env ] && [ -f $ROOT/.env ]; then
echo "Reading from .env files..."
source "$BASE/.env"
source "$ROOT/.env"
else
echo "No .env file found, creating..."
echo "DATABASE_PASSWORD=$DATABASE_PASSWORD" > $BASE/.env
echo "NIFI_PASSWORD=$NIFI_PASSWORD" >> $BASE/.env
echo "KEYCLOAK_ADMIN_PASSWORD=$KEYCLOAK_ADMIN_PASSWORD" >> $BASE/.env

echo "DATABASE_PASSWORD=$DATABASE_PASSWORD" > $ROOT/.env
echo "TOKEN_SECRET=$TOKEN_SECRET" >> $ROOT/.env
echo "PARAMETER_SECRET=$PARAMETER_SECRET" >> $ROOT/.env

# Supplmental values
echo 'NBS_DATASOURCE_SERVER=nbs-mssql' >> $ROOT/.env
echo 'CLASSIC_SERVICE=wildfly:7001' >> $ROOT/.env
echo 'MODERNIZATION_SERVICE=${MODERNIZATION_API_SERVER:-modernization-api}:${MODERNIZATION_API_PORT:-8080}' >> $ROOT/.env
echo 'UI_SERVICE=${MODERNIZATION_UI_SERVER:-modernization-api}:${MODERNIZATION_UI_PORT:-8080}' >> $ROOT/.env
echo 'PAGEBUILDER_SERVICE=${PAGEBUILDER_API_SERVER:-pagebuilder-api}:${PAGEBUILDER_API_PORT:-8095}' >> $ROOT/.env
echo 'NBS_SECURITY_OIDC_ENABLED=${OIDC_ENABLED:-false}' >> $ROOT/.env
echo 'NBS_SECURITY_OIDC_URI=${ISSUER_URI:-http://keycloak:8080/realms/nbs-users}' >> $ROOT/.env
echo 'PAGEBUILDER_ENABLED=true' >> $ROOT/.env


fi

0 comments on commit f436f5d

Please sign in to comment.