Skip to content

Commit

Permalink
Updates documentation and base versions in Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund committed Dec 13, 2024
1 parent ecbb4a1 commit e641245
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi9/nodejs-18:1-112.1719561319 AS builder
FROM registry.access.redhat.com/ubi9/nodejs-18:9.5-1733148761 AS builder

WORKDIR /opt/app-root/src

Expand All @@ -9,16 +9,16 @@ RUN mkdir -p /opt/app-root/src/node_modules && \
npm ci && \
npm run build

FROM registry.access.redhat.com/ubi9/nodejs-18:1-112.1719561319
FROM registry.access.redhat.com/ubi9/nodejs-18:9.5-1733148761

## Uncomment the below lines to update image security content if any
# USER root
# RUN dnf -y update-minimal --security --sec-severity=Important --sec-severity=Critical && dnf clean all

LABEL name="ibm/template-node-typescript" \
vendor="IBM" \
version="1" \
release="112" \
version="9" \
release="5" \
summary="This is an example of a container image." \
description="This container image will deploy a Typescript Node App"

Expand Down
93 changes: 90 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,22 @@ igc pipeline

To get started building this application locally, you can either run the application natively or use the [IBM Cloud Developer Tools](https://cloud.ibm.com/docs/cli?topic=cloud-cli-getting-started) for containerization and easy deployment to IBM Cloud.

#### Container Build

The following commands can be used to build with podman:

```bash
podman build -t watsonx-demo-svc .
```

#### Native Application Development

Install the latest [Node.js](https://nodejs.org/en/download/) 6+ LTS version.
Install the latest [Node.js](https://nodejs.org/en/download/) 18 LTS version.

Once the Node toolchain has been installed, you can download the project dependencies with:

```bash
npm install
cd client; npm install; cd ..
npm ci
npm run build
npm run start
```
Expand All @@ -86,6 +93,86 @@ npm run start

Your application will be running at `http://localhost:3000`. You can access the `/health` and `/appmetrics-dash` endpoints at the host.

### Configure Application

The following environment variables configure the application:

| Variable | Description | Default variable |
|-------------------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| CRA_BASE_PATH | Base url for the CP4BA business rules engine | |
| IAM_URL | Url of the IAM service to authenticate users | https://iam.cloud.ibm.com/identity/token |
| DISCOVERY_URL | Url of the Watson Discovery instance | |
| DATA_EXTRACTION_PROJECT_ID | ID of the Watson Discovery project for the Data Extraction service | |
| DATA_EXTRACTION_COLLECTION_ID | ID of the Watson Discovery collection for the Data Extraction service | |
| DECODING_METHOD | The GenAI decoding method: greedy or sampling | greedy |
| REPETITION_PENALTY | | 1 |
| WML_URL | Url of the Watson Machine Learning service | https://us-south.ml.cloud.ibm.com/ml/v1-beta/generation/text?version=2023-05-28 |
| WML_PROJECT_ID | ID of the Watson Machine Learning Project | |
| DISCOVERY_PROJECT_ID | ID of the Watson Discovery project used for other services | |
| DISCOVERY_VERSION | Watson Discovery version string used in API calls | 2020-08-30 |
| FIND_PASSAGE_CONCURRENCY | The number of concurrent processes for finding passages in Watson Discovery | 20 |
| KYC_PROJECT_ID | ID of the Watson Discovery project used for KYC services | |
| KYC_COLLECTION_ID | ID of the Watson Discovery collection for KYC services | |
| KYC_SUMMARY_URL | Url of the KYC Summary service | |
| MODEL_ID | ID of the model used by the application | google/flan-t5-xxl |
| MAX_NEW_TOKENS | | 20 |
| RELEVANT_PASSAGES_URL | Url of the relevant passages service | |
| CLOUDANT_URL | Url for Cloudant DB service | |
| CLOUDANT_API_KEY | API Key for Cloudant DB service | |
| CLOUDANT_USERNAME | Username for Cloudant DB service | |
| CRA_API_KEY | API Key for CRA service | |
| CRA_USERNAME | Username for CRA service | |
| DISCOVERY_API_KEY | API Key for Watson Discovery service | |
| SCRAPEIT_API_KEY | API Key for Scrapeit service | |
| WML_API_KEY | API Key for Watson Machine Learning service | |
| MONGODB_PASSWORD | Password for MongoDB service | |
| MONGODB_USERNAME | Username for MongoDB service | |
| MONGODB_CONNECT_STRING | Connect string for MongoDB service | |
| MONGODB_DATABASE_NAME | Name of MongoDB database | |
| MONGODB_CERTIFICATE_FILE | Certificate file contents for MongoDB database | |

#### Configure locally

A template for the environment variables are stored in `.env.template`. To run locally copy the `.env.template` file to
`.env` and update the variables in the file to match the environment. The .gitignore file is set up so that the `.env` file
will not be checked in.

## Code structure

The source code for the application is contained under the `src/` folder

### Controllers

The controllers folder contains REST controllers. The controller operations are defined using nestjs annotations and
structured logically around different business functions. The nestjs annotations also set up swagger documentation
and the Swagger UI has been enabled by default to view and interact with the API specs.

As a design point, the Controllers are designed to translate from REST protocol into typescript code and usable data types.
However, the Controllers should not directly contain any business logic. Rather, they use the logic provided in the `services`
layer.

### Resolvers

The resolvers folder contains the GraphQL resolvers to expose the business logic over GraphQL protocols. The resolver operations
are defined using nestjs annotations and structured logically around different business functions. A GraphQL Explorer site is enabled
by default to view and interact with the GraphQL schemas and endpoints.

As a design point, the Resolvers are designed to translate from GraphQL protocol into typescript code and usable data types.
However, the Resolvers should not directly contain any business logic. Rather, they use the logic provided in the `services` layer.

### Services

The services folder contains the business logic for the application. The service layer uses IoC (Inversion of Control) apis from
nestjs to allow different interface implementations based on configuration values.

### Models

The models folder contains data model definitions for the different service components.

### GraphQL Types

The graphql-types folder contains GraphQL wrapper types for the various model components.

## Next Steps

* Learn more about augmenting your Node.js applications on IBM Cloud with the [Node Programming Guide](https://cloud.ibm.com/docs/node?topic=nodejs-getting-started).
Expand Down

0 comments on commit e641245

Please sign in to comment.