Skip to content

Commit

Permalink
Merge pull request #36 from metabolomics-us/QA
Browse files Browse the repository at this point in the history
FIEHNLAB-1600/FixSimilarityService,FIEHNLAB-1130/Documentation,Simplifying Deployment
  • Loading branch information
NolanGuzman97 authored Mar 25, 2022
2 parents ff44a17 + 870c131 commit f1a2fcb
Show file tree
Hide file tree
Showing 35 changed files with 424 additions and 197 deletions.
74 changes: 74 additions & 0 deletions .run/Build Proxy Staging.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Proxy Prod" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="clean" />
<option value="install" />
<option value="-Denvironment=prod" />
</list>
</option>
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map>
<entry key="nexus" value="true" />
<entry key="test-jar" value="false" />
<entry key="doc-jar" value="false" />
<entry key="scala" value="true" />
<entry key="source-jar" value="false" />
<entry key="docker-proxy" value="false" />
<entry key="scala-test" value="false" />
<entry key="docker" value="true" />
</map>
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/backend/app/server/proxy" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
<configuration default="false" name="Build Proxy Staging" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="clean" />
<option value="install" />
<option value="-Denvironment=staging" />
</list>
</option>
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map>
<entry key="nexus" value="true" />
<entry key="test-jar" value="false" />
<entry key="doc-jar" value="false" />
<entry key="scala" value="true" />
<entry key="source-jar" value="false" />
<entry key="docker-proxy" value="false" />
<entry key="scala-test" value="false" />
<entry key="docker" value="true" />
</map>
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/backend/app/server/proxy" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
38 changes: 38 additions & 0 deletions .run/Deploy Proxy Prod.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Deploy Proxy Prod" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="clean" />
<option value="deploy" />
<option value="-Denvironment=prod" />
</list>
</option>
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map>
<entry key="nexus" value="true" />
<entry key="test-jar" value="false" />
<entry key="doc-jar" value="false" />
<entry key="scala" value="true" />
<entry key="source-jar" value="false" />
<entry key="docker-proxy" value="false" />
<entry key="scala-test" value="false" />
<entry key="docker" value="true" />
</map>
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/backend/app/server/proxy" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
38 changes: 38 additions & 0 deletions .run/Deploy Proxy Staging.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Deploy Proxy Staging" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings" />
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="clean" />
<option value="deploy" />
<option value="-Denvironment=staging" />
</list>
</option>
<option name="pomFileName" value="pom.xml" />
<option name="profilesMap">
<map>
<entry key="nexus" value="true" />
<entry key="test-jar" value="false" />
<entry key="doc-jar" value="false" />
<entry key="scala" value="true" />
<entry key="source-jar" value="false" />
<entry key="docker-proxy" value="false" />
<entry key="scala-test" value="false" />
<entry key="docker" value="true" />
</map>
</option>
<option name="resolveToWorkspace" value="false" />
<option name="workingDirPath" value="$PROJECT_DIR$/backend/app/server/proxy" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<method v="2" />
</configuration>
</component>
102 changes: 75 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,85 @@
# README #
# MassBank of North America Application

ports for cluster service nodes:
## Common:
- Highly Recommended to use Linux OS (Preferably Ubuntu LTS 18.04 or 20.04)
- Ensure you have the following installed
- Node Version Manager(NVM)
- Docker Engine (And Docker-Compose)
- NPM (Node Package Manager)
- Angular CLI 10.2.3
- IntelliJ IDEA Ultimate
- Maven 3 (Should be baked into IntelliJ)
- Git
- AWS CLI (for ECR to pull docker images)
- Java 1.8_292 (open_jdk x64)
- Scala 2.13
- Installs in IntelliJ
- Right-click the main 'mona' project and click 'Add Framework Support'
- Gain Access to the following
- Internal mona-config private repo
- You'll need admin access and will need to generate a Personal Access Token (https://github.com/settings/tokens)
- Then open your `~/.bash_rc` and set the following variables, 'GIT_USER' and 'GIT_PASS' to your github username and
new personal access token. This allows the discovery service to work as intended
- Note: You'll need to set these tokens on the IPA and GOSE servers as they expire every year (you can configure
how quickly these expire).
- Access to AWS account and ability to push to ECR
- Admin access to public mona repo
- You'll need a settings.xml file for your maven 'User Settings File' this will include the nexus profile
and all the necessary repo's for pulling down libraries. Please ask a developer on the team for this config
and store file at `~/.m2`


## Starting Development:
- There are 3 scripts in the project to easily start development
- `./start_corsproxy.sh`
- Solves CORS issues when connecting the frontend to the microservices
- `./start_docker_dev.sh`
- Starts all necessary docker microservices
- `./start_frontend.sh`
- Starts the Angular 10 frontend with ng serve to develop on the fly

## PROD Deployment:
- Production deployment is simple with docker
- Bring down the application with: `docker stack rm mona`
- Bring the application back up with `docker stack deploy -c docker-compose-prod.yml`
- Note: You may need to force the newest images to pull down with `docker-compose -f docker-compose-prod.yml pull`

## Running Test Suite With IntelliJ and Maven:
- Using the built-in Maven tab, we can run the full scala test suite
- Make sure the following Maven profiles are selected (and only those): nexus, scala, scala-test
- Run the following docker-compose file: `docker-compose -f docker-compose-test.yml -d`
- Finally, run `mvn clean install` on the 'backend(root)'

## Generate new Docker Images:
- Make sure the following Maven profiles are selected (and only those): nexus, scala, docker
- The following services can be built into docker images: discovery, bootstrap, webhooks-server,curation-scheduler,
repository, persistence-server, auth-server, similarity, proxy, download-scheduler, and curation-runner
- `mvn clean install` will build a local docker image for the corresponding service
- `mvn clean deploy` will build the docker image and deploy it to ECR (make sure you signed in to AWS CLI)
- default tag is 'test' you can easily configure that in the main mona pom.xml
- NOTE: For the proxy service pom.xml, you'll need to configure the 'ng.env' variable to 'staging' or 'prod'
depending on if the build is for IPA('staging') or GOSE('prod');

## Important Development Notes:
- Make sure project sdk/jdk is set to Java 1.8_292
- Make sure to configure Maven in IntelliJ IDEA to use the same project jdk which should be Java 1.8_292
- Make sure you added framework support for scala 2.13 in IntelliJ for the mona project
- When making a new branch for git, naming convention should typically have a ticket number (i.e. FIEHN-1234) following
a slash and a description of the ticket (i.e. FIEHN-1234/ThisIsATicket).
- If your having issues pulling packages with maven, you can troubleshoot with deleting your `~/.m2/repository` directory.
Additionally, ensure you have the correct 'settings.xml' file in `~/.m2`. If problems still persist, try the 'Invalidate
Caches' under File tab in IntelliJ IDEA.


### ports for cluster service nodes:
- persistence svr: 2222
- configuration svr: 1111
- discovery service: 8761
- auth server: 3333
- proxy service: 8080 (entry point)


ports for in-memory node:
### ports for in-memory node:
- embedded mongo db: 27017
- mona rest client: 8080
- elasticsearch client: 9200
- elasticsearch web???: 9300

Building the nodes:

Common:
- check/setup docker configuration
for Mac/Win:
eval "$(docker-machine env default)"
for linux:
N/A
- run 'mvn clean install' on the backend folder to compile and create the docker images

To run the in-memory node docker continer:
- To create the containers manually:
run 'docker run [--name <whateveryouwanttonameyourimage>] -p=80:8080 [-p=9200:9200 -p=9300:9300 -p=27017:27017] eros.fiehnlab.ucdavis.edu/mona-memory-node'
to start the docker container of choice

To run the cluster service nodes using docker compose: (WIP)
- To run the cluster node using docker-compose:
'cd app/compose'
run 'docker-compose up -d'

- elasticsearch web: 9300
4 changes: 2 additions & 2 deletions backend/app/server/proxy/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# GhostProject
# MoNA Angular 10 Frontend

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.2.3.

## Development server

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

## Code scaffolding

Expand Down
19 changes: 15 additions & 4 deletions backend/app/server/proxy/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,21 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
"maximumWarning": "5mb",
"maximumError": "8mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
"maximumWarning": "10kb",
"maximumError": "15kb"
}
]
},
"staging": {
"fileReplacements": [
{
"replace": "src/main/mona-web/src/environments/environment.ts",
"with": "src/main/mona-web/src/environments/environment.staging.ts"
}
]
}
Expand All @@ -93,6 +101,9 @@
"configurations": {
"production": {
"browserTarget": "proxy:build:production"
},
"staging": {
"browserTarget": "proxy:build:staging"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion backend/app/server/proxy/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/app/server/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "ng serve",
"build": "ng build",
"prod": "ng build --prod",
"staging": "ng build --configuration=staging",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng src/main/mona-web/e2e"
Expand Down
3 changes: 2 additions & 1 deletion backend/app/server/proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<properties>
<docker.expose>8080</docker.expose>
<ng.env>staging</ng.env>
</properties>

<dependencies>
Expand Down Expand Up @@ -136,7 +137,7 @@
<goal>npm</goal>
</goals>
<configuration>
<arguments>run prod</arguments>
<arguments>run ${ng.env}</arguments>
</configuration>
</execution>
</executions>
Expand Down
Loading

0 comments on commit f1a2fcb

Please sign in to comment.