Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Feature/embedded external deps (#11)
Browse files Browse the repository at this point in the history
* Add new gradle tasks for embedded mysql and embedded dashboard and reverse
proxy
  • Loading branch information
fieldju authored Jan 9, 2017
1 parent 9f05512 commit 0836bb0
Show file tree
Hide file tree
Showing 7 changed files with 447 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,9 @@ local.properties
cms-local-overrides.conf
/one_login_mfa_api_tester.sh
/cms_login_tester.sh

# node plugin stuffs
/reverse_proxy/node_modules/

# embedded mysql stuff
/target/
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ To learn more about Cerberus, please visit the [Cerberus website](http://enginee

## Getting Started

### Running with embedded Vault, Mysql

If you do not wish to install and run MySQL and Vault locally you can run these embedded using gradlew see the `Running CMS Locally` section

gradlew runVaultAndMySQL

### Running with persistent data,

If you wish to persist data permanently you can install Vault and MySQL locally

**MySQL** is required to run the application locally.

To get MySQL setup on OS X:
Expand Down Expand Up @@ -111,7 +121,7 @@ auth.connector.okta.base_url | Yes | The Okta base url (e.g. `"htt

## Running CMS Locally

First, a few properties must be configured in `cms-core-code/src/main/resources/cms-local-overrides.conf`
First, a few properties must be configured in `src/main/resources/cms-local-overrides.conf`

You'll need a few pieces of information before you can run the application:

Expand Down Expand Up @@ -139,21 +149,44 @@ You'll need a few pieces of information before you can run the application:
cms.auth.connector=<YOUR AUTH CONNECTOR CLASS>
```

### Using Gradle and embedded dependencies (Vault, MySql and the reverse proxy and Dashboard)

If you wish to use embedded Vault, MySQL and run the Dashboard with reverse proxy run each of the following tasks in new command line terminals as they each are blocking tasks

- `gradlew runVaultAndMySQL`
- Works on Windows, Mac, Unix
- Downloads and configures embedded MySQL.
- Downloads configures and runs Vault,
- You can control Vault version with `vaultVersion` in `gradle/develop.gradle`
- This task needs to be run as Admin in Windows, ensure that you start the IDE or Terminals as Admin
- `gradlew runCMS`
- Works on Windows, Mac, Unix
- Auto-sets the Vault system props and starts CMS
- To debug attach remote debugger to port 5005
- If you wish to do IAM auth in dev mode you will need to make sure you set your env as described http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
- `gradlew runDashboardAndReverseProxy`
- OPTIONAL TASK, Works on Windows, Mac, Unix
- Runs the dashboard and reverse into interact with CMS, sometimes better than curling or using postman.
- Downloads the dashboard from GitHub releases and runs an express server and reverse proxy to expose `http://localhost:9000/dashboard/`
- You can change dashboard version with `dashboardRelease` in `gradle/develop.gradle`
- `gradlew bootstrapData`
- OPTIONAL TASK, Adds some data test data to Cerberus since `runVaultAndMySQL` is ephemeral and deletes everything when the process ends.

### From the IDE


With Vault and MySQL running
Simply run `com.nike.cerberus.Main`. The following VM arguments should be set:

-D@appId=cms -D@environment=local -Dvault.addr=http://localhost:8200 -Dvault.token=<token>

Note that if the VAULT_ADDR and VAULT_TOKEN environment variables are set, you don't need vault.addr or vault.token VM arguments.

### From the CLI

With Vault and MySQL running

./gradlew clean build

./debugShadowJar.sh -Dvault.addr=http://localhost:8200 -Dvault.token=<token>

Note that if the VAULT_ADDR and VAULT_TOKEN environment variables are set, you don't need vault.addr or vault.token VM arguments.

## Setting up your IDE

Expand Down
14 changes: 3 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ buildscript {

plugins {
id "org.flywaydb.flyway" version "4.0.3"
id "com.moowork.node" version "1.0.1"
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'embedded-mysql'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down Expand Up @@ -131,14 +133,4 @@ task antReplace() {
}
}

task runCMS(type: JavaExec) {
dependsOn 'antReplace'
classpath = sourceSets.main.runtimeClasspath
main = 'com.nike.cerberus.Main'
systemProperties = [
'vault.addr': 'http://127.0.0.1:8200',
'vault.token': System.getenv('VAULT_TOKEN'),
'@appId': 'cms',
'@environment': 'local'
]
}
apply from: file('gradle/develop.gradle')
2 changes: 2 additions & 0 deletions gradle/buildscript.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
classpath 'com.github.ksoichiro:gradle-console-reporter:0.4.0'
classpath group: 'com.typesafe', name: 'config', version: '1.3.1'
classpath group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.7.1'
classpath 'com.github.michaelruocco:embedded-mysql-plugin:2.1.4'
}
Loading

0 comments on commit 0836bb0

Please sign in to comment.