diff --git a/.gitmodules b/.gitmodules index 8b1378917..8bc8740e0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1 +1,4 @@ +[submodule "inspector"] + path = inspector + url = https://github.com/gradido/inspector.git diff --git a/README.md b/README.md index 986066efa..a36be6e19 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Clone the Gradido repository to your local machine. ```bash git clone https://github.com/gradido/gradido.git cd gradido +git submodule update --init --recursive ``` For local development, you can run Gradido with **Docker** or **natively**, depending on your preferences and system setup. If you don't have a native MariaDB or MySQL installation, Docker can be used to handle the database as well. @@ -227,6 +228,16 @@ In root folder calling `bun clear` will clear all turbo caches, node_modules and bun clear ``` +### git Submodule +The new Module `inspector` was added as git submodule. +So after +- `git clone` +- `git checkout` +- `git pull` + +you have to run `git submodule update --init` to get the correct submodule version. + +[Read More](https://git-scm.com/book/en/v2/Git-Tools-Submodules) ## Services defined in this package diff --git a/backend/.env.dist b/backend/.env.dist index 8d5ba317c..f9fcb035f 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -1,5 +1,5 @@ # Server -PORT=4000 +BACKEND_PORT=4000 JWT_SECRET=secret123 JWT_EXPIRES_IN=10m GRAPHIQL=false @@ -22,7 +22,7 @@ KLICKTIPP_APIKEY_DE=SomeFakeKeyDE KLICKTIPP_APIKEY_EN=SomeFakeKeyEN # DltConnector -DLT_CONNECTOR=true +DLT_ACTIVE=false DLT_CONNECTOR_URL=http://localhost:6010 # Community diff --git a/backend/.env.template b/backend/.env.template index 9b0bc7df2..98090546d 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -1,11 +1,11 @@ # must match the CONFIG_VERSION.EXPECTED definition in scr/config/index.ts -CONFIG_VERSION=$BACKEND_CONFIG_VERSION # Server JWT_SECRET=$JWT_SECRET JWT_EXPIRES_IN=$JWT_EXPIRES_IN GRAPHIQL=false GDT_API_URL=$GDT_API_URL +BACKEND_PORT=$BACKEND_PORT # Database DB_HOST=127.0.0.1 @@ -24,7 +24,7 @@ KLICKTIPP_APIKEY_DE=$KLICKTIPP_APIKEY_DE KLICKTIPP_APIKEY_EN=$KLICKTIPP_APIKEY_EN # DltConnector -DLT_CONNECTOR=$DLT_CONNECTOR +DLT_ACTIVE=$DLT_ACTIVE DLT_CONNECTOR_PORT=$DLT_CONNECTOR_PORT # Community diff --git a/backend/.env.test_e2e b/backend/.env.test_e2e index e7f3a29c8..1a6c3a214 100644 --- a/backend/.env.test_e2e +++ b/backend/.env.test_e2e @@ -1,5 +1,6 @@ # Server JWT_EXPIRES_IN=2m +BACKEND_PORT=4000 GDT_ACTIVE=false HUMHUB_ACTIVE=false diff --git a/backend/Dockerfile b/backend/Dockerfile index d3d549cab..8cebcbe8d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -17,7 +17,7 @@ ENV BUILD_COMMIT="0000000" ## SET NODE_ENV ENV NODE_ENV=production ## App relevant Envs -ENV PORT="4000" +ENV BACKEND_PORT="4000" ## Timezone ENV TZ=UTC ENV DB_HOST=mariadb @@ -42,7 +42,7 @@ LABEL maintainer="support@gradido.net" # Settings ## Expose Container Port -EXPOSE ${PORT} +EXPOSE ${BACKEND_PORT} ## Workdir RUN mkdir -p ${DOCKER_WORKDIR} diff --git a/backend/src/apis/dltConnector/DltConnectorClient.test.ts b/backend/src/apis/dltConnector/DltConnectorClient.test.ts index e3673791b..55acb6e04 100644 --- a/backend/src/apis/dltConnector/DltConnectorClient.test.ts +++ b/backend/src/apis/dltConnector/DltConnectorClient.test.ts @@ -5,17 +5,17 @@ import { DltConnectorClient } from './DltConnectorClient' describe('undefined DltConnectorClient', () => { it('invalid url', () => { CONFIG.DLT_CONNECTOR_URL = '' - CONFIG.DLT_CONNECTOR = true + CONFIG.DLT_ACTIVE = true const result = DltConnectorClient.getInstance() expect(result).toBeUndefined() CONFIG.DLT_CONNECTOR_URL = 'http://dlt-connector:6010' }) - it('DLT_CONNECTOR is false', () => { - CONFIG.DLT_CONNECTOR = false + it('DLT_ACTIVE is false', () => { + CONFIG.DLT_ACTIVE = false const result = DltConnectorClient.getInstance() expect(result).toBeUndefined() - CONFIG.DLT_CONNECTOR = true + CONFIG.DLT_ACTIVE = true }) }) diff --git a/backend/src/apis/dltConnector/DltConnectorClient.ts b/backend/src/apis/dltConnector/DltConnectorClient.ts index a5e162ba0..2a1ced85d 100644 --- a/backend/src/apis/dltConnector/DltConnectorClient.ts +++ b/backend/src/apis/dltConnector/DltConnectorClient.ts @@ -31,7 +31,7 @@ export class DltConnectorClient { * just one instance of each subclass around. */ public static getInstance(): DltConnectorClient | undefined { - if (!CONFIG.DLT_CONNECTOR || !CONFIG.DLT_CONNECTOR_URL) { + if (!CONFIG.DLT_ACTIVE || !CONFIG.DLT_CONNECTOR_URL) { logger.info(`dlt-connector are disabled via config...`) return } diff --git a/backend/src/apis/dltConnector/__mocks__/DltConnectorClient.ts b/backend/src/apis/dltConnector/__mocks__/DltConnectorClient.ts index 81a7c5398..5a2c96d79 100644 --- a/backend/src/apis/dltConnector/__mocks__/DltConnectorClient.ts +++ b/backend/src/apis/dltConnector/__mocks__/DltConnectorClient.ts @@ -30,7 +30,7 @@ export class DltConnectorClient { * just one instance of each subclass around. */ public static getInstance(): DltConnectorClient | undefined { - if (!CONFIG.DLT_CONNECTOR || !CONFIG.DLT_CONNECTOR_URL) { + if (!CONFIG.DLT_ACTIVE || !CONFIG.DLT_CONNECTOR_URL) { logger.info(`dlt-connector are disabled via config...`) return } diff --git a/backend/src/apis/dltConnector/index.ts b/backend/src/apis/dltConnector/index.ts index bce319674..dd192b82c 100644 --- a/backend/src/apis/dltConnector/index.ts +++ b/backend/src/apis/dltConnector/index.ts @@ -64,7 +64,7 @@ async function executeDltTransaction(draft: TransactionDraft | null, typeId: Dlt * and update dltTransactionId of transaction in db with hiero transaction id */ export async function registerAddressTransaction(user: DbUser, community: DbCommunity): Promise { - if (!CONFIG.DLT_CONNECTOR) { + if (!CONFIG.DLT_ACTIVE) { return Promise.resolve(null) } if (!user.id) { @@ -88,7 +88,7 @@ export async function contributionTransaction( signingUser: DbUser, createdAt: Date, ): Promise { - if (!CONFIG.DLT_CONNECTOR) { + if (!CONFIG.DLT_ACTIVE) { return Promise.resolve(null) } const homeCommunity = await getHomeCommunity() @@ -107,7 +107,7 @@ export async function transferTransaction( memo: string, createdAt: Date ): Promise { - if (!CONFIG.DLT_CONNECTOR) { + if (!CONFIG.DLT_ACTIVE) { return Promise.resolve(null) } // load community if not already loaded, maybe they are remote communities @@ -125,7 +125,7 @@ export async function transferTransaction( export async function deferredTransferTransaction(senderUser: DbUser, transactionLink: DbTransactionLink) : Promise { - if (!CONFIG.DLT_CONNECTOR) { + if (!CONFIG.DLT_ACTIVE) { return Promise.resolve(null) } // load community if not already loaded @@ -138,7 +138,7 @@ export async function deferredTransferTransaction(senderUser: DbUser, transactio export async function redeemDeferredTransferTransaction(transactionLink: DbTransactionLink, amount: string, createdAt: Date, recipientUser: DbUser) : Promise { - if (!CONFIG.DLT_CONNECTOR) { + if (!CONFIG.DLT_ACTIVE) { return Promise.resolve(null) } // load user and communities if not already loaded diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 8af6e739a..9a57fed43 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -16,7 +16,8 @@ const logging = { } const server = { - PORT: process.env.PORT ?? 4000, + BACKEND_PORT: process.env.BACKEND_PORT ?? 4000, + DLT_ACTIVE: process.env.DLT_ACTIVE === 'true' || false, JWT_SECRET: process.env.JWT_SECRET ?? 'secret123', JWT_EXPIRES_IN: process.env.JWT_EXPIRES_IN ?? '10m', REDEEM_JWT_TOKEN_EXPIRATION: process.env.REDEEM_JWT_TOKEN_EXPIRATION ?? '10m', @@ -41,9 +42,7 @@ const COMMUNITY_URL = process.env.COMMUNITY_URL ?? `${URL_PROTOCOL}://${COMMUNIT const DLT_CONNECTOR_PORT = process.env.DLT_CONNECTOR_PORT ?? 6010 const dltConnector = { - DLT_CONNECTOR: process.env.DLT_CONNECTOR === 'true' || false, DLT_CONNECTOR_URL: process.env.DLT_CONNECTOR_URL ?? `${COMMUNITY_URL}:${DLT_CONNECTOR_PORT}`, - DLT_GRADIDO_NODE_SERVER_HOME_FOLDER: process.env.DLT_GRADIDO_NODE_SERVER_HOME_FOLDER ?? '~/.gradido', } const community = { diff --git a/backend/src/config/schema.ts b/backend/src/config/schema.ts index 64871715c..2f65435cc 100644 --- a/backend/src/config/schema.ts +++ b/backend/src/config/schema.ts @@ -4,6 +4,7 @@ import { COMMUNITY_SUPPORT_MAIL, COMMUNITY_URL, DECAY_START_TIME, + DLT_ACTIVE, GDT_ACTIVE, GDT_API_URL, GMS_ACTIVE, @@ -27,6 +28,7 @@ export const schema = Joi.object({ COMMUNITY_DESCRIPTION, COMMUNITY_SUPPORT_MAIL, DECAY_START_TIME, + DLT_ACTIVE, GDT_API_URL, GDT_ACTIVE, GMS_ACTIVE, @@ -68,20 +70,11 @@ export const schema = Joi.object({ .default('http://0.0.0.0/redeem/CL-') .required(), - DLT_CONNECTOR: Joi.boolean() - .description('Flag to indicate if DLT-Connector is used. (Still in development)') - .default(false) - .required(), - DLT_CONNECTOR_URL: Joi.string() .uri({ scheme: ['http', 'https'] }) .default('http://localhost:6010') - .when('DLT_CONNECTOR', { is: true, then: Joi.required() }) - .description('The URL for GDT API endpoint'), - - DLT_GRADIDO_NODE_SERVER_HOME_FOLDER: Joi.string() - .default('~/.gradido') - .description('The home folder for the gradido dlt node server'), + .when('DLT_ACTIVE', { is: true, then: Joi.required() }) + .description('The URL for DLT connector'), EMAIL_LINK_VERIFICATION: Joi.string() .uri({ scheme: ['http', 'https'] }) @@ -179,7 +172,7 @@ export const schema = Joi.object({ }) .description('JWT key for HumHub integration, must be the same as configured in humhub'), - PORT: Joi.number() + BACKEND_PORT: Joi.number() .integer() .min(1024) .max(49151) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index ea48c3458..bb5787378 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -42,7 +42,7 @@ const logErrorLogger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.server.LogError`) jest.mock('@/password/EncryptorUtils') -CONFIG.DLT_CONNECTOR = false +CONFIG.DLT_ACTIVE = false // mock semaphore to allow use fake timers // jest.mock('database/src/util/TRANSACTIONS_LOCK') diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index 9cf45f633..523620177 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -40,7 +40,7 @@ import { AppDatabase } from 'database' jest.mock('@/password/EncryptorUtils') const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.server.LogError`) -CONFIG.DLT_CONNECTOR = false +CONFIG.DLT_ACTIVE = false CORE_CONFIG.EMAIL = false let mutate: ApolloServerTestClient['mutate'] diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index f38c8b22a..b055c7975 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -119,7 +119,7 @@ beforeAll(async () => { con = testEnv.con db = testEnv.db CONFIG.HUMHUB_ACTIVE = false - CONFIG.DLT_CONNECTOR = false + CONFIG.DLT_ACTIVE = false await cleanDB() }) diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 3eda49644..f104507e7 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -29,7 +29,7 @@ import { AppDatabase } from 'database' jest.mock('@/password/EncryptorUtils') -CONFIG.DLT_CONNECTOR = false +CONFIG.DLT_ACTIVE = false CORE_CONFIG.EMAIL = false let mutate: ApolloServerTestClient['mutate'] diff --git a/backend/src/index.ts b/backend/src/index.ts index 283554a9d..db4bf76b5 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -12,12 +12,12 @@ async function main() { const { app } = await createServer(getLogger('apollo')) await writeJwtKeyPairInHomeCommunity() - app.listen(CONFIG.PORT, () => { + app.listen(CONFIG.BACKEND_PORT, () => { // biome-ignore lint/suspicious/noConsole: no need for logging the start message - console.log(`Server is running at http://localhost:${CONFIG.PORT}`) + console.log(`Server is running at http://localhost:${CONFIG.BACKEND_PORT}`) if (CONFIG.GRAPHIQL) { // biome-ignore lint/suspicious/noConsole: no need for logging the start message - console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`) + console.log(`GraphIQL available at http://localhost:${CONFIG.BACKEND_PORT}`) } }) await startValidateCommunities(Number(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER)) diff --git a/config-schema/src/commonSchema.ts b/config-schema/src/commonSchema.ts index 250ea3182..f28115ea7 100644 --- a/config-schema/src/commonSchema.ts +++ b/config-schema/src/commonSchema.ts @@ -35,6 +35,11 @@ export const COMMUNITY_URL = Joi.string() .default('http://0.0.0.0') .required() +export const DLT_ACTIVE = Joi.boolean() + .description('Flag to indicate if the DLT (Decentralized Ledger Technology) service is used.') + .default(false) + .required() + export const GRAPHQL_URI = Joi.string() .uri({ scheme: ['http', 'https'] }) .description( diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 729fc84aa..7be3ead1e 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -12,6 +12,8 @@ EMAIL_PASSWORD=1234 EMAIL_SMTP_HOST=smtp.lustig.de EMAIL_SMTP_PORT=587 +BACKEND_PORT=4000 + # if set to true allow sending gradidos to another communities FEDERATION_XCOM_SENDCOINS_ENABLED=false @@ -85,9 +87,14 @@ FEDERATION_COMMUNITY_APIS=1_0 # externe gradido services (more added in future) GDT_ACTIVE=false +AUTO_POLL_INTERVAL=30000 + # DLT-Connector (still in develop) -DLT_CONNECTOR=false +DLT_ACTIVE=false DLT_CONNECTOR_PORT=6010 +DLT_NODE_SERVER_PORT=8340 +DLT_NODE_SERVER_URL=$URL_PROTOCOL://$COMMUNITY_HOST/dlt +DLT_GRADIDO_NODE_SERVER_VERSION=0.9.0 DLT_GRADIDO_NODE_SERVER_HOME_FOLDER=/home/gradido/.gradido # used for combining a newsletter on klicktipp with this gradido community diff --git a/deployment/bare_metal/nginx/sites-available/gradido-dlt.conf.template b/deployment/bare_metal/nginx/sites-available/gradido-dlt.conf.template new file mode 100644 index 000000000..0fd2ba985 --- /dev/null +++ b/deployment/bare_metal/nginx/sites-available/gradido-dlt.conf.template @@ -0,0 +1,46 @@ + # Blockchain Explorer + location /inspector { + limit_req zone=frontend burst=30 nodelay; + limit_conn addr 20; + alias $PROJECT_ROOT/inspector/build/; + index index.html; + + # caching rules for assets + # static assets + location ~* \.(?:woff2?|ttf|otf|eot|jpg|jpeg|png|gif|svg|webp|ico)$ { + # keep assets for a week + add_header Cache-Control "public, max-age=604800"; + try_files $uri =404; + } + # hashed assets + location ~* \.(?:js|css|json)$ { + add_header Cache-Control "public, max-age=31536000, immutable"; + try_files $uri =404; + } + + try_files $uri $uri/ /index.html = 404; + + # don't cache index.html + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires 0; + + access_log $GRADIDO_LOG_PATH/nginx-access.inspector.log gradido_log; + error_log $GRADIDO_LOG_PATH/nginx-error.inspector.log warn; + } + + # Gradido-Node + location /dlt { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + + proxy_pass http://127.0.0.1:$DLT_NODE_SERVER_PORT/api; + proxy_redirect off; + + access_log $GRADIDO_LOG_PATH/nginx-access.dlt.log gradido_log; + error_log $GRADIDO_LOG_PATH/nginx-error.dlt.log warn; + } \ No newline at end of file diff --git a/deployment/bare_metal/nginx/sites-available/gradido.conf.ssl.template b/deployment/bare_metal/nginx/sites-available/gradido.conf.ssl.template index 3bc911d39..72ac17390 100644 --- a/deployment/bare_metal/nginx/sites-available/gradido.conf.ssl.template +++ b/deployment/bare_metal/nginx/sites-available/gradido.conf.ssl.template @@ -196,6 +196,9 @@ server { access_log $GRADIDO_LOG_PATH/nginx-access.admin.log gradido_log; error_log $GRADIDO_LOG_PATH/nginx-error.admin.log warn; } + + # dlt + $DLT_NGINX_CONF # Federation $FEDERATION_NGINX_CONF diff --git a/deployment/bare_metal/start.sh b/deployment/bare_metal/start.sh index 19cafc077..80ef55d39 100755 --- a/deployment/bare_metal/start.sh +++ b/deployment/bare_metal/start.sh @@ -185,6 +185,7 @@ cd $PROJECT_ROOT git fetch --all git checkout $BRANCH_NAME git pull +git submodule update --init --recursive export BUILD_COMMIT="$(git rev-parse HEAD)" # install missing dependencies @@ -213,6 +214,15 @@ unset FEDERATION_APIVERSION unset FEDERATION_PORT log_step "====================================================================================================" +export DLT_NGINX_CONF="${DLT_NGINX_CONF:-# dlt disabled}" +# prepare inspector and gradido dlt node nginx config blocks if enabled +if [ "$DLT_ACTIVE" = true ] ; then + log_step "prepare inspector and dlt gradido node nginx config block" + envsubst '$DLT_NODE_SERVER_PORT' < $NGINX_CONFIG_DIR/gradido-dlt.conf.template >> $NGINX_CONFIG_DIR/gradido-dlt.conf + export DLT_NGINX_CONF=$(< $NGINX_CONFIG_DIR/gradido-dlt.conf) + rm $NGINX_CONFIG_DIR/gradido-dlt.conf +fi + # *** 2nd read gradido-federation.conf file in env variable to be replaced in 3rd step export FEDERATION_NGINX_CONF=$(< $NGINX_CONFIG_DIR/gradido-federation.conf.locations) @@ -222,8 +232,9 @@ case "$URL_PROTOCOL" in 'https') TEMPLATE_FILE="gradido.conf.ssl.template" ;; *) TEMPLATE_FILE="gradido.conf.template" ;; esac -envsubst '$FEDERATION_NGINX_CONF' < $NGINX_CONFIG_DIR/$TEMPLATE_FILE > $NGINX_CONFIG_DIR/gradido.conf.tmp +envsubst '$FEDERATION_NGINX_CONF,$DLT_NGINX_CONF' < $NGINX_CONFIG_DIR/$TEMPLATE_FILE > $NGINX_CONFIG_DIR/gradido.conf.tmp unset FEDERATION_NGINX_CONF +unset DLT_NGINX_CONF envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $NGINX_CONFIG_DIR/gradido.conf.tmp > $NGINX_CONFIG_DIR/gradido.conf rm $NGINX_CONFIG_DIR/gradido.conf.tmp rm $NGINX_CONFIG_DIR/gradido-federation.conf.locations @@ -245,6 +256,10 @@ MODULES=( dht-node federation ) +if [ "$DLT_ACTIVE" = true ] ; then + MODULES+=("inspector") + MODULES+=("dlt-connector") +fi if [ "$FAST_MODE" = false ] ; then log_step 'Clean tmp, bun and yarn cache' @@ -275,7 +290,10 @@ fi log_step 'Regenerate .env files' for dir in "${MODULES[@]}"; do base="$PROJECT_ROOT/$dir" - cp -f $base/.env $base/.env.bak + # Backup .env file if exists + if [ -f "$base/.env" ]; then + cp -f $base/.env $base/.env.bak + fi envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $base/.env.template > $base/.env done @@ -287,6 +305,21 @@ bun install log_step 'build all modules' turbo build --env-mode=loose --concurrency=$(nproc) +# build inspector and dlt-connector +if [ "$DLT_ACTIVE" = true ]; then + log_step 'build inspector' + cd $PROJECT_ROOT/inspector + bun install + bun run build + + log_step 'build dlt-connector' + cd $PROJECT_ROOT/dlt-connector + bun install + bun run build + + cd $PROJECT_ROOT +fi + # database log_step 'Updating database' if [ "$DEPLOY_SEED_DATA" = "true" ]; then @@ -306,6 +339,14 @@ pm2 start --name gradido-backend \ -l $GRADIDO_LOG_PATH/pm2.backend.$TODAY.log \ --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' +if [ "$DLT_ACTIVE" = true ] ; then + pm2 start --name dlt-connector \ + "env TZ=UTC NODE_ENV=production bun ./build/index.js" \ + --cwd $PROJECT_ROOT/dlt-connector \ + -l $GRADIDO_LOG_PATH/pm2.dlt-connector.$TODAY.log \ + --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS' +fi + pm2 save if [ ! -z $FEDERATION_DHT_TOPIC ]; then pm2 start --name gradido-dht-node \ diff --git a/dlt-connector/.env.dist b/dlt-connector/.env.dist index 8253699ca..165ca7bd0 100644 --- a/dlt-connector/.env.dist +++ b/dlt-connector/.env.dist @@ -1,19 +1,20 @@ -CONFIG_VERSION=v6.2024-02-20 - # SET LOG LEVEL AS NEEDED IN YOUR .ENV # POSSIBLE VALUES: all | trace | debug | info | warn | error | fatal # LOG_LEVEL=info -# IOTA -IOTA_API_URL=https://chrysalis-nodes.iota.org -IOTA_COMMUNITY_ALIAS=GRADIDO: TestHelloWelt2 -IOTA_HOME_COMMUNITY_SEED=aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899 +HOME_COMMUNITY_SEED=aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899 # DLT-Connector DLT_CONNECTOR_PORT=6010 # Gradido Node Server URL DLT_NODE_SERVER_PORT=8340 +DLT_GRADIDO_NODE_SERVER_VERSION=0.9.0 + +HIERO_ACTIVE=true +HIERO_HEDERA_NETWORK=testnet +HIERO_OPERATOR_ID="YOUR_OPERATOR_ID" +HIERO_OPERATOR_KEY="YOUR_OPERATOR_ED25519_PRIVATE_KEY_IN_DER_FORMAT" # Gradido Blockchain GRADIDO_BLOCKCHAIN_CRYPTO_APP_SECRET=21ffbbc616fe diff --git a/dlt-connector/.env.template b/dlt-connector/.env.template new file mode 100644 index 000000000..92819f579 --- /dev/null +++ b/dlt-connector/.env.template @@ -0,0 +1,25 @@ +# SET LOG LEVEL AS NEEDED IN YOUR .ENV +# POSSIBLE VALUES: all | trace | debug | info | warn | error | fatal +# LOG_LEVEL=info + +HOME_COMMUNITY_SEED=$HOME_COMMUNITY_SEED + +# DLT-Connector +DLT_CONNECTOR_PORT=$DLT_CONNECTOR_PORT + +# Gradido Node Server URL +DLT_NODE_SERVER_PORT=$DLT_NODE_SERVER_PORT +DLT_GRADIDO_NODE_SERVER_VERSION=$DLT_GRADIDO_NODE_SERVER_VERSION + +HIERO_ACTIVE=$HIERO_ACTIVE +HIERO_HEDERA_NETWORK=$HIERO_HEDERA_NETWORK +HIERO_OPERATOR_ID=$HIERO_OPERATOR_ID +HIERO_OPERATOR_KEY=$HIERO_OPERATOR_KEY + +# Gradido Blockchain +GRADIDO_BLOCKCHAIN_CRYPTO_APP_SECRET=$GRADIDO_BLOCKCHAIN_CRYPTO_APP_SECRET +GRADIDO_BLOCKCHAIN_SERVER_CRYPTO_KEY=$GRADIDO_BLOCKCHAIN_SERVER_CRYPTO_KEY + +# Route to Backend +BACKEND_PORT=$BACKEND_PORT +JWT_SECRET=$JWT_SECRET \ No newline at end of file diff --git a/dlt-connector/src/client/backend/BackendClient.ts b/dlt-connector/src/client/backend/BackendClient.ts index 7f779fd73..ce9660e36 100644 --- a/dlt-connector/src/client/backend/BackendClient.ts +++ b/dlt-connector/src/client/backend/BackendClient.ts @@ -30,7 +30,7 @@ export class BackendClient { */ private constructor() { this.logger = getLogger(`${LOG4JS_BASE_CATEGORY}.client.BackendClient`) - this.urlValue = `http://localhost:${CONFIG.PORT}` + this.urlValue = `http://localhost:${CONFIG.BACKEND_PORT}` this.logger.addContext('url', this.urlValue) this.client = new GraphQLClient(this.urlValue, { diff --git a/dlt-connector/src/config/schema.ts b/dlt-connector/src/config/schema.ts index 67a43383d..9490e8a00 100644 --- a/dlt-connector/src/config/schema.ts +++ b/dlt-connector/src/config/schema.ts @@ -80,14 +80,17 @@ export const configSchema = v.object({ '8340', ), DLT_GRADIDO_NODE_SERVER_VERSION: v.optional( - v.string('The version of the DLT node server'), + v.pipe( + v.string('The version of the DLT node server, for example: 0.9.0'), + v.regex(/^\d+\.\d+\.\d+$/), + ), '0.9.0', ), DLT_GRADIDO_NODE_SERVER_HOME_FOLDER: v.optional( v.string('The home folder for the gradido dlt node server'), path.join(__dirname, '..', '..', 'gradido_node'), ), - PORT: v.optional( + BACKEND_PORT: v.optional( v.pipe( v.string('A valid port on which the backend server is running'), v.transform((input: string) => Number(input)), diff --git a/docker-compose.override.yml b/docker-compose.override.yml index bc17f0d64..ebd5dc484 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -43,6 +43,26 @@ services: # bind the local folder to the docker to allow live reload - .:/app + ######################################################## + # INSPECTOR ############################################ + ######################################################## + inspector: + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/inspector:local-development + build: + target: development + networks: + - external-net + - internal-net + environment: + - NODE_ENV=development + volumes: + # This makes sure the docker container has its own node modules. + # Therefore it is possible to have a different node version on the host machine + - node_modules_inspector:/app/node_modules + # bind the local folder to the docker to allow live reload + - .:/app + ######################################################## # BACKEND ############################################## ######################################################## @@ -216,6 +236,7 @@ volumes: node_modules_frontend: node_modules_backend: node_modules_federation: + node_modules_inspector: node_modules_database: node_modules_dlt_connector: turbo_cache: diff --git a/docker-compose.yml b/docker-compose.yml index 4d305b4bc..3a8590095 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -61,6 +61,30 @@ services: volumes: - ./logs/nginx/admin:/var/log/nginx + ######################################################## + # INSPECTOR ########################################### + ######################################################## + inspector: + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/inspector:local-production + build: + context: ./inspector + dockerfile: Dockerfile + target: production + networks: + - internal-net + ports: + - ${INSPECTOR_MODULE_PORT:-3100}:3100 + environment: + - NODE_ENV=production + - BUILD_COMMIT=${BUILD_COMMIT} + - BUILD_COMMIT_SHORT=${BUILD_COMMIT_SHORT} + - BUILD_VERSION=${BUILD_VERSION} + # - DEBUG=true + volumes: + - ./logs/nginx/inspector:/var/log/nginx + + ######################################################### ## MARIADB ############################################## ######################################################### @@ -109,7 +133,7 @@ services: environment: # Envs used in Dockerfile # - DOCKER_WORKDIR="/app" - # - PORT=4000 + - BACKEND_PORT=4000 - BUILD_DATE - BUILD_VERSION - BUILD_COMMIT @@ -144,7 +168,6 @@ services: environment: # Envs used in Dockerfile # - DOCKER_WORKDIR="/app" - # - PORT=5000 - BUILD_DATE - BUILD_VERSION - BUILD_COMMIT @@ -179,7 +202,8 @@ services: environment: # Envs used in Dockerfile # - DOCKER_WORKDIR="/app" - - PORT=6010 + - DLT_CONNECTOR_PORT=6010 + - BACKEND_PORT=4000 - BUILD_DATE - BUILD_VERSION - BUILD_COMMIT diff --git a/frontend/src/components/ContentFooter.vue b/frontend/src/components/ContentFooter.vue index e749d0cd9..d6f120e49 100755 --- a/frontend/src/components/ContentFooter.vue +++ b/frontend/src/components/ContentFooter.vue @@ -43,6 +43,9 @@ {{ $t('navigation.support') }} + + {{ $t('footer.inspector') }} + @@ -54,6 +57,8 @@ import CONFIG from '@/config' export default { data() { return { + dltActive: CONFIG.DLT_ACTIVE, + communityUrl: CONFIG.COMMUNITY_URL, year: new Date().getFullYear(), version: CONFIG.APP_VERSION, hash: CONFIG.BUILD_COMMIT, diff --git a/frontend/src/config/index.js b/frontend/src/config/index.js index f75ef910f..d1d9966f8 100644 --- a/frontend/src/config/index.js +++ b/frontend/src/config/index.js @@ -38,6 +38,7 @@ if (process.env.FRONTEND_HOSTING === 'nodejs') { // version.FRONTEND_MODULE_PORT const features = { + DLT_ACTIVE: process.env.DLT_ACTIVE === 'true', GMS_ACTIVE: process.env.GMS_ACTIVE === 'true', HUMHUB_ACTIVE: process.env.HUMHUB_ACTIVE === 'true', AUTO_POLL_INTERVAL: Number.parseInt(process.env.AUTO_POLL_INTERVAL ?? 0), diff --git a/frontend/src/config/schema.js b/frontend/src/config/schema.js index c7f7817b8..745e24b74 100644 --- a/frontend/src/config/schema.js +++ b/frontend/src/config/schema.js @@ -9,6 +9,7 @@ import { COMMUNITY_URL, DEBUG, DECAY_START_TIME, + DLT_ACTIVE, GMS_ACTIVE, GRAPHQL_URI, HUMHUB_ACTIVE, @@ -30,6 +31,7 @@ module.exports = Joi.object({ COMMUNITY_URL, DEBUG, DECAY_START_TIME, + DLT_ACTIVE, GMS_ACTIVE, GRAPHQL_URI, HUMHUB_ACTIVE, diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 4e9cdfdd5..e1429b8d5 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -158,6 +158,7 @@ "year": "© {year}" }, "imprint": "Impressum", + "inspector": "Inspektor (experimentell)", "privacy_policy": "Datenschutzerklärung", "short_hash": "({shortHash})", "whitepaper": "Whitepaper" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 9e96a497b..f0c4fab94 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -158,6 +158,7 @@ "year": "© {year}" }, "imprint": "Legal notice", + "inspector": "Inspector (experimental)", "privacy_policy": "Privacy policy", "short_hash": "({shortHash})", "whitepaper": "Whitepaper" diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index 905466540..1e7344cbb 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -140,6 +140,7 @@ "year": "© {year}" }, "imprint": "Aviso legal", + "inspector": "Inspector (experimental)", "privacy_policy": "Protección de Datos", "short_hash": "({shortHash})", "whitepaper": "Whitepaper" diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index 8024d468e..4caa05686 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -145,6 +145,7 @@ "year": "© {year}" }, "imprint": "Notification légale", + "inspector": "Inspecteur (expérimental)", "privacy_policy": "Politique de confidentialité", "short_hash": "({shortHash})", "whitepaper": "Papier blanc" diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json index 98eb6d2ad..16568e294 100644 --- a/frontend/src/locales/nl.json +++ b/frontend/src/locales/nl.json @@ -140,6 +140,7 @@ "year": "© {year}" }, "imprint": "Colofon", + "inspector": "Inspecteur (experimenteel)", "privacy_policy": "Privacyverklaring", "short_hash": "({shortHash})", "whitepaper": "Witboek" diff --git a/frontend/vite.config.mjs b/frontend/vite.config.mjs index 4a0674b0f..d722601d0 100644 --- a/frontend/vite.config.mjs +++ b/frontend/vite.config.mjs @@ -114,6 +114,7 @@ export default defineConfig(async ({ command }) => { AUTO_POLL_INTERVAL: CONFIG.AUTO_POLL_INTERVAL, BUILD_COMMIT: CONFIG.BUILD_COMMIT, CROSS_TX_REDEEM_LINK_ACTIVE: CONFIG.CROSS_TX_REDEEM_LINK_ACTIVE, + DLT_ACTIVE: CONFIG.DLT_ACTIVE, GMS_ACTIVE: CONFIG.GMS_ACTIVE, HUMHUB_ACTIVE: CONFIG.HUMHUB_ACTIVE, DEFAULT_PUBLISHER_ID: null, diff --git a/inspector b/inspector new file mode 160000 index 000000000..c7fc92da3 --- /dev/null +++ b/inspector @@ -0,0 +1 @@ +Subproject commit c7fc92da31e80a27558d3887543446079dc55b5e