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

Containerization #15

Open
wants to merge 42 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1e9e590
category test
caspater Feb 4, 2020
77afd3b
unit tests
caspater Feb 5, 2020
a3b46e1
e2e for menu
caspater Feb 10, 2020
81d09e4
menu unit test
caspater Feb 10, 2020
7911727
e2e tests
caspater Feb 10, 2020
c5213e4
e2e file update
caspater Feb 10, 2020
07b2135
search link
caspater Feb 12, 2020
ac22514
search container state and table data
caspater Feb 12, 2020
8a00fad
search store
caspater Feb 12, 2020
ce0d82f
loading states
caspater Feb 12, 2020
f10be96
error states 500
caspater Feb 12, 2020
4a5b1cb
error states
caspater Feb 12, 2020
3bc2a57
search unit test
caspater Feb 12, 2020
cf017aa
Download functionality
caspater Feb 14, 2020
e767b31
updated tests
caspater Feb 14, 2020
1138f47
category icons and description
caspater Feb 17, 2020
eebf61d
global search
caspater Feb 17, 2020
367a159
update snap tests
caspater Feb 18, 2020
7531b03
e2e tests
caspater Mar 5, 2020
dbe260a
initial liking of front and backend
brett-onions Mar 5, 2020
34bd167
Merge remote-tracking branch 'origin/test-terminology-client' into li…
brett-onions Mar 5, 2020
e78987c
removing package-lock.json file
brett-onions Mar 5, 2020
23b125b
fixing issues with search
brett-onions Mar 5, 2020
3cd7f1a
adding .env.example file
brett-onions Mar 5, 2020
e7b97c1
fixed search bg
caspater Mar 5, 2020
f693a5d
logo link
caspater Mar 6, 2020
5e2bf8b
category card spacing and icon color
caspater Mar 6, 2020
c1378a9
updated links and breadcrumb
caspater Mar 6, 2020
d578141
removed dev tools
caspater Mar 6, 2020
626fbc3
added error boundary
caspater Mar 6, 2020
72a1dcf
Updating Readme.md
brett-onions Mar 6, 2020
32632b1
Adding missing section to readme
brett-onions Mar 6, 2020
1dadaf4
Adding Docker Files
brett-onions Mar 10, 2020
340c02e
responsiveness
caspater Mar 10, 2020
4f9b60b
environment variables
caspater Mar 10, 2020
cbcbd7f
Merge branch 'linking-back-and-front-end' of https://github.com/Kuuni…
caspater Mar 10, 2020
5a3f433
Adding Product Master Redis
brett-onions Mar 10, 2020
98af463
Merge branch 'linking-back-and-front-end' of https://github.com/Kuuni…
brett-onions Mar 10, 2020
2fd37ae
Containerization Terminology Service
brett-onions Mar 11, 2020
7a2bf76
Dockerising ts and pm
brett-onions Mar 16, 2020
13b2a79
Increased Seach threshold and Added Docker to .md
brett-onions Mar 16, 2020
1c8b936
Update README.md
brett-onions Mar 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
OCL_API_KEY=''
OCL_API='https://api.openconceptlab.org/'
OCL_CATEGORIES_API_URL=''
OCL_PRODUCT_MASTER_SOURCE=''
OCL_PRODUCT_MASTER_DHIS2=''
OCL_PRODUCT_MASTER_DHAMIS=''
OCL_PRODUCT_MASTER_OPENLMIS=''
REDIS_HOST='docker-redis'
REDIS_PORT='6379'
TERMINOLOGY_SERVICE_API_VERSION='v0'
PRODUCT_MASTER_API='v0'
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#env

#env
.env
.environment.prod.ts
.environment.ts

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules
package-lock.json

# IDEs and editors
/.idea
Expand Down Expand Up @@ -39,3 +43,4 @@ testem.log
# System Files
.DS_Store
Thumbs.db

2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "0.2.0",
"configurations": [
"configurations": [
{
"name": "Debug Jest",
"type": "node",
Expand Down
3 changes: 0 additions & 3 deletions Dockerfile

This file was deleted.

212 changes: 168 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,200 @@
# Kuunika
# Kuunika - Mono Repo

This project was generated using [Nx](https://nx.dev).
This repo hosts a number of Kuunika projects and was generated using [Nx](https://nx.dev/) to help manage the mono repo architecture.

<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png" width="450"></p>

🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**

## Adding capabilities to your workspace
## Table of Contents

Nx supports many plugins which add capabilities for developing different types of applications and different tools.
- Terminology Service Dashboard
- Further Help

These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.

Below are some plugins which you can add to your workspace:

- [React](https://reactjs.org)
- `npm install --save-dev @nrwl/react`
- Web (no framework frontends)
- `npm install --save-dev @nrwl/web`
- [Angular](https://angular.io)
- `npm install --save-dev @nrwl/angular`
- [Nest](https://nestjs.com)
- `npm install --save-dev @nrwl/nest`
- [Express](https://expressjs.com)
- `npm install --save-dev @nrwl/express`
- [Node](https://nodejs.org)
- `npm install --save-dev @nrwl/node`
# Terminology Service Dashboard

## Generate an application
## Dependencies

Run `nx g @nrwl/react:app my-app` to generate an application.
- [NodeJS > v10.15.0](https://nodejs.org/en/download/)
- [Redis > 5.0.7](https://redis.io/download)

> You can use any of the plugins above to generate applications as well.

When using Nx, you can create multiple applications and libraries in the same workspace.

## Generate a library
## Setup

Run `nx g @nrwl/react:lib my-lib` to generate a library.
This project uses NestJs for its api backend and ReactJs for front end. Click the following link to thier respective documentation for more information on [NestJs](https://docs.nestjs.com/) and [ReactJS](https://reactjs.org/docs/getting-started.html) .

> You can also use any of the plugins above to generate libraries as well.
This installation guide assumes that you have read and setup Open Concept Lab according to the guide provided in the Kuunika Repos [Wiki](https://github.com/Kuunika/kuunika/wiki/Terminology-Service-Dashboard---Configuring-Open-Concept-Lab).

Libraries are sharable across libraries and applications. They can be imported from `@kuunika/mylib`.

## Development server

Run `nx serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
## Installation

## Code scaffolding
#### Step 1: Clone Repo

Run `nx g @nrwl/react:component my-component --project=my-app` to generate a new component.
Clone this repository into your local directory, Use the command below:

## Build
```bash
# Clone project to a computer
git clone https://github.com/Kuunika/kuunika

Run `nx build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
# Navigate to the project root directory
cd kuunika
```

## Running unit tests
#### Step 2: Install Dependencies

Run `nx test my-app` to execute the unit tests via [Jest](https://jestjs.io).
In the root directory of the project run the following command

Run `nx affected:test` to execute the unit tests affected by a change.
```bash
# install all dependancies
npm install
```

## Running end-to-end tests
#### Step 3: Run Tests

Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).
```shell
# install all dependancies
npm run test
```

Run `nx affected:e2e` to execute the end-to-end tests affected by a change.
#### Step 4: Edit Env File

## Understand your workspace
In the root directory there exist a file named *'.env.example'* create a copy of this file, rename the copy to *'.env'* and open it to edit the contents.

Run `nx dep-graph` to see a diagram of the dependencies of your projects.
```bash
# API key used to make request to the OCL API Service
OCL_API_KEY='*'

## Further help
OCL_API='*' #Base URL Of OCL or URL of internally hosted instance of OCL, ex https://api.openconceptlab.org/

Visit the [Nx Documentation](https://nx.dev) to learn more.
OCL_CATEGORIES_API_URL='*' #URL of Source containing categories data that the api will route requests, ex: orgs/:OrgName/sources/:SampleSourceName/

REDIS_HOST=* #Address of Redis instance host

REDIS_PORT='6379' #Port used to access redis. Default port 6379
```

#### Step 5: Populate Redis With Data From OCL

```shell
# Command for populating Redis with OCL Data
npm run terminology-redis
```

#### Step 6: Start Backend

In the root directory of the project run the following command and the api will be running on port 3333

```shell
# Command for starting the backend api
npm run terminology-api
```

#### Step 7: Start Frontend

In the root directory of the project run the following command and the frontend will be running on port 4200

```shell
# Command for starting the frontend
npm run terminology-client
```

## Docker Installation

### Step 1: Clone Repo

Clone this repository into your local directory, Use the command below:

```bash
# Clone project to a computer
git clone https://github.com/Kuunika/kuunika

# Navigate to the project root directory
cd kuunika
```

### Step 2: Create/Edit .ENV File

Copy and Rename the .env.example to .env, next modifiy the file.

```shell
# API key used to make request to the OCL API Service
OCL_API_KEY='*'

OCL_API='*' #Base URL Of OCL or URL of internally hosted instance of OCL, ex https://api.openconceptlab.org/

OCL_CATEGORIES_API_URL='*' #URL of Source containing categories data that the api will route requests, ex: orgs/:OrgName/sources/:SampleSourceName/

# ignore the following for the deploment of terminology service
OCL_PRODUCT_MASTER_SOURCE=''
OCL_PRODUCT_MASTER_DHIS2=''
OCL_PRODUCT_MASTER_DHAMIS=''
OCL_PRODUCT_MASTER_OPENLMIS=''
# end of the ignored ENVs

REDIS_HOST=* #Address of Redis instance host

REDIS_PORT='6379' #Port used to access redis. Default port 6379
```



### Step 3: Building Map Files for

```shell
# Creating Terminology-Api Map Files
nx build terminology-api

# Creating Terminology-Redis Map Files
nx build terminology-redis

# Creating Terminology-Client Map Files
nx build terminology-client
```



### Step 4: Build Docker Images

```shell
# Creating Terminology-Api Image
docker image build -t docker-terminology-api -f terminology-api.Dockerfile .

# Creating Terminology-Redis Image
docker image build -t docker-terminology-redis -f terminology-redis.Dockerfile .

# Creating Terminology-client Image
docker image build -t docker-terminology-client -f terminology-client.Dockerfile .
```



### Step 5: Run Docker Compose

```shell
# Run this command to setup the containers into a network
docker-compose up
```

Once started await this message to be logged in the console.

```shell
docker-terminology-redis | Terminology service cache successfully created.
```



After the message is displayed navigate to http://127.0.0.1 in a web browser.



# Further Help

### Addictional Information

Additional information can be found on project's [Wiki](https://github.com/Kuunika/kuunika/wiki)

### Reporting Issues

If you have noticed a bug, you can open an issue on our [Github](https://github.com/Kuunika/kuunika/issues) Repo Page and attempt to fix.
1 change: 1 addition & 0 deletions apps/product-master-api/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "../../.eslintrc", "rules": {} }
5 changes: 5 additions & 0 deletions apps/product-master-api/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
name: 'product-master-api',
preset: '../../jest.config.js',
coverageDirectory: '../../coverage/apps/product-master-api'
};
Empty file.
24 changes: 24 additions & 0 deletions apps/product-master-api/src/app/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';

import { AppController } from './app.controller';
import { AppService } from './app.service';

describe('AppController', () => {
let app: TestingModule;

beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService]
}).compile();
});

describe('getData', () => {
it('should return "Welcome to product-master-api!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({
message: 'Welcome to product-master-api!'
});
});
});
});
13 changes: 13 additions & 0 deletions apps/product-master-api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common';

import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
getData() {
return this.appService.getData();
}
}
12 changes: 12 additions & 0 deletions apps/product-master-api/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { DataElementsModule } from '../data-elements/data-elements.module';

@Module({
imports: [ DataElementsModule],
controllers: [AppController],
providers: [AppService]
})
export class AppModule {}
23 changes: 23 additions & 0 deletions apps/product-master-api/src/app/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Test } from '@nestjs/testing';

import { AppService } from './app.service';

describe('AppService', () => {
let service: AppService;

beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService]
}).compile();

service = app.get<AppService>(AppService);
});

describe('getData', () => {
it('should return "Welcome to product-master-api!"', () => {
expect(service.getData()).toEqual({
message: 'Welcome to product-master-api!'
});
});
});
});
8 changes: 8 additions & 0 deletions apps/product-master-api/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
getData(): { message: string } {
return { message: 'Welcome to product-master-api!' };
}
}
Empty file.
Loading