Skip to content

Commit

Permalink
Liquid Prep node backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav-Ramakrishna committed Mar 31, 2023
1 parent 4276648 commit fab0e81
Show file tree
Hide file tree
Showing 26 changed files with 935 additions and 201 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore node modules
node_modules/

# Ignore unwanted project files for the image
resources/
images/
*.md
dist/
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#Node build stage
FROM node:lts-bullseye-slim as builder

# Change working directory
WORKDIR /build

COPY . .

# Install npm packages
RUN npm install

# Complie typescript and build dist package
RUN npm run build

# Node production stage
# New node image to run the built package in production
FROM node:lts-bullseye-slim

ENV NODE_ENV production

# Change working directory
WORKDIR /server

COPY package.json .

# Install npm packages
RUN npm install rxjs --save-prod
RUN npm install --omit-dev


# copy all required files to production image
COPY --from=builder /build/dist /server/dist
COPY --from=builder /build/.env /server

EXPOSE 5000

# Start the backend service
CMD ["node", "dist/index.js"]
71 changes: 71 additions & 0 deletions IBM-Cloudant-DB-Setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Setup IBM Cloudant Database

Follow the instructions to setup and configure IBM Cloudant Database on IBM Cloud.

## Pre-requisites

1. **IBM Cloud Account**
- [Create an IBM Cloud account to setup a Cloudant Database](https://cloud.ibm.com/registration)

## Configure Cloudant Database on IBM Cloud

- Enter **Cloudant** in the IBM Cloud search bar and select **Cloudant**.

<p align="middle">
<img src="images/cloudant/searchCloudant.PNG" width ="30%" height="30%">
</p>

- Next configure the Cloudant DB,

- Under **Select an environment** section, enter Instance Name as **Cloudant-liquidPrep**.

- Select **IAM** as Authentication method.

- Select a suitable pricing Plan – Lite, Standard and Standard on Transaction Engine.

<p align="middle">
<img src="images/cloudant/configureCloudant.PNG" width ="30%" height="30%">
</p>

- Select **Create** on the bottom right pane of Cloudant dashboard. A message will be displayed to say that the instance is being provisioned, which returns you to the Resource list. From the Resource list, you see the status for your instance is, **Provision in progress.**

<p align="middle">
<img src="images/cloudant/activeCloudant.PNG" width ="30%" height="30%">
</p>

- When status of the instance changes to **Active**, click the **Cloudant-liquidPrep** instance and select **Service Credentials** tab on left pane of dashboard. Select **New Credential**, enter Name as **liquid-prep** and Role as **Manager**. A service credential will be created.

<p align="middle">
<img src="images/cloudant/serviceCredsCloudant.PNG" width ="30%" height="30%">
</p>

- Select **Manage** tab on the left pane and select **Launch Dashboard** on the top right of the page. It will launch a Cloudant dashboard to create new database.

- On the Databases page, select **Create Database** on the top right of the Cloudant dashboard.
- Enter Database name as **liquid-prep-crops**. Select the Partitioning option as **Non-partitioned**. And click on **Create** button at the bottom.

<p align="middle">
<img src="images/cloudant/createDBCloudant.PNG" width ="15%" height="30%">
</p>

- The **liquid-prep-crops** database will be created and listed in Databases page.

- Select **liquid-prep-crops** and click on **Create Document** on top right of the page. A document with auto generated **\_id** key will open.

<p align="middle">
<img src="images/cloudant/createDoc_cloudant.PNG" width ="30%" height="30%">
</p>

- Go to Liquid Prep project directory `~/LiquidPrep-Node-Backend/resources/crops`. Open each crop document, copy the contents in the document and paste it in the **New Document** that was opened in **liquid-prep-crops** database and click **Create Document** button.

- Example for Corn crop;
<p align="middle">
<img src="images/cloudant/createDoc_cloudant_corn.PNG" width ="30%" height="30%">
</p>

- Corn document will be created and listed in **liquid-prep-crops** database.
<p align="middle">
<img src="images/cloudant/liquidPrep_cloudant_cropsList.PNG" width ="30%" height="30%">
</p>

- Similarly, repeat previous step for all the other crop documents.
Loading

0 comments on commit fab0e81

Please sign in to comment.