Skip to content

Commit

Permalink
Merge branch 'master' into sourcefusegh-382
Browse files Browse the repository at this point in the history
  • Loading branch information
samarpan-b authored Oct 20, 2021
2 parents bd34424 + e87892a commit e6a2db0
Show file tree
Hide file tree
Showing 139 changed files with 72,345 additions and 49 deletions.
95 changes: 54 additions & 41 deletions sandbox/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
# Sandbox Examples
The sandbox examples have been pre-configured with a `docker-compose` file for easy setup. Please examine the environment variables in the file prior to running and change the variables where appropriate. For example, if you want to test the Keycloak integration, plugin your configuration values to the `docker-compose.yml` file.

The sandbox examples have been pre-configured with a `docker-compose` file for easy setup. Please examine the environment variables in the file prior to running and change the variables where appropriate. For example, if you want to test the Keycloak integration, plugin your configuration values to the `docker-compose.yml` file.

## Basic Setup

You must have `docker-compose` installed locally. This is not a production grade setup.

To start the services, simply run from this directory.

```shell
docker-compose up --build
```

If you would like the services to run in detached mode, supply the `-d` parameter.

The services are now running under the following:
* [audit-ms-example](http://localhost:3032/explorer)
* [notification-example](http://localhost:3030/explorer)
* [auth-multitenant-example](http://localhost:3000/explorer)
* [in-mail-example](http://localhost:3033/explorer)
* [notification-socket-example](http://localhost:3030/explorer)
* [scheduler-example](http://localhost:3034/explorer)
* [video-conferencing-ms-example](http://localhost:3040/explorer)
* [workflow-ms-example](http://localhost:3031/explorer)
* [Camunda](http://localhost:8080)
* [pgAdmin](http://localhost:5050)
* PostgreSQL - localhost:5432
* Redis - localhost:6739

- [audit-ms-example](http://localhost:3032/explorer)
- [notification-example](http://localhost:3030/explorer)
- [auth-multitenant-example](http://localhost:3000/explorer)
- [in-mail-example](http://localhost:3033/explorer)
- [notification-socket-example](http://localhost:3030/explorer)
- [scheduler-example](http://localhost:3034/explorer)
- [video-conferencing-ms-example](http://localhost:3040/explorer)
- [workflow-ms-example](http://localhost:3031/explorer)
- [chat-notification-pubnub-example](http://localhost:3050/explorer)
- [Camunda](http://localhost:8080)
- [pgAdmin](http://localhost:5050)
- PostgreSQL - localhost:5432
- Redis - localhost:6739

Credentials for the database and pgAdmin are in the `docker-compose` file or can be overridden with environment variables. An orchestration container creates all of the databases and another runs the service DB migrations for you.

Expand Down Expand Up @@ -149,9 +154,10 @@ istio-system job.batch/istio-security-post-install-1.5.1 1/1 82s
istio-system job.batch/istio-grafana-post-install-1.5.1 1/1 82s 25d

```

</details>

Change your working directory to `./sandbox`
Change your working directory to `./sandbox`

Run the build script

Expand All @@ -161,8 +167,8 @@ chmod +x ./build.sh
./build.sh
```

Now create the `sourceloop-sandbox` namespace.
:exclamation: Skip this step if you plan on using `terrform` to deploy. :exclamation:
Now create the `sourceloop-sandbox` namespace.
:exclamation: Skip this step if you plan on using `terrform` to deploy. :exclamation:

```sh
$ microk8s kubectl apply -f k8s/manifests/namespaces/
Expand All @@ -186,7 +192,7 @@ Switched to context "sourceloop-sandbox".
```

Now create the rest of the resources:
:exclamation: Skip this step if you plan on using `terrform` to deploy. :exclamation:
:exclamation: Skip this step if you plan on using `terrform` to deploy. :exclamation:

```sh
microk8s kubectl apply -f k8s/manifests/ --recursive
Expand All @@ -205,16 +211,17 @@ To avoid adding a host header to every request, add the following entries to you
127.0.0.1 camunda.sourceloop.local
```

You're local setup is now up and running.
You're local setup is now up and running.

To view the dashboard, run

```sh
$ microk8s dashboard-proxy
```

### MicroK8s
If you run into issue, these are the commands you may need to run locally, manually.
### MicroK8s

If you run into issue, these are the commands you may need to run locally, manually.

The contents of this function can be found in the `ci_build.sh` file located in `sandbox/ci_build.sh`

Expand All @@ -235,49 +242,55 @@ install_microk8s() {

If you prefer to use the Terraform module, follow the steps below. Terraform `1.0.3` + is required.

Perform the same steps above to:
* Enable `microk8s` services
* Running the container build script
* Set the context
* Adding host header entries
Perform the same steps above to:

- Enable `microk8s` services
- Running the container build script
- Set the context
- Adding host header entries

Once the above steps are complete, you can proceed to run the following:

Once the above steps are complete, you can proceed to run the following:
```sh
cd k8s/tf-sourceloop-sandbox
terraform init
terraform apply
```

:warning: **Issues**:
* <details open="true">

- <details open="true">
<summary>connection refused</summary>
If you get an error similar the following, it shows you are unable to connect to the resources:
```

If you get an error similar the following, it shows you are unable to connect to the resources:

```
kubernetes_namespace.sourceloop_sandbox: Creating...
│ Error: Post "http://localhost/api/v1/namespaces": dial tcp 127.0.0.1:80: connect: connection refused
│ with kubernetes_namespace.sourceloop_sandbox,
│ on namespace.tf line 1, in resource "kubernetes_namespace" "sourceloop_sandbox":
│ 1: resource "kubernetes_namespace" "sourceloop_sandbox" {
```

You will need to execute the following in order to copy the kube config to the `.kube` folder: `microk8s config > $HOME/.kube/config`

---
If you downloaded MicroK8s using snap, and you get an error like the following:


***

If you downloaded MicroK8s using snap, and you get an error like the following:

```
/snap/microk8s/2346/bin/sed: couldn't flush stdout: Permission denied
```
You will can run `microk8s config` and manually copy the console output to `~/.kube/config`.

You will can run `microk8s config` and manually copy the console output to `~/.kube/config`.

</details>
* Terraform apply failed on resource creation.
* Give it about five minutes then re-run `terraform apply`, all resources should now properly apply.

See the [readme](./k8s/tf-sourceloop-sandbox/README.md) for more information on the Terraform module.
- Terraform apply failed on resource creation.
- Give it about five minutes then re-run `terraform apply`, all resources should now properly apply.

See the [readme](./k8s/tf-sourceloop-sandbox/README.md) for more information on the Terraform module.
1 change: 1 addition & 0 deletions sandbox/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ docker push ${REGISTRY}/audit-ms-example
docker push ${REGISTRY}/scheduler-example
docker push ${REGISTRY}/video-conferencing-ms-example
docker push ${REGISTRY}/in-mail-example
docker push ${REGISTRY}/chat-notification-pubnub-example
5 changes: 5 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
npm-debug.log
/dist
# Cache used by TypeScript's incremental build
*.tsbuildinfo
4 changes: 4 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
coverage/
.eslintrc.js
3 changes: 3 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '@loopback/eslint-config',
};
64 changes: 64 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# 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

# nyc test coverage
.nyc_output

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

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

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# Transpiled JavaScript files from Typescript
/dist

# Cache used by TypeScript's incremental build
*.tsbuildinfo
5 changes: 5 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"exit": true,
"recursive": true,
"require": "source-map-support/register"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
*.json
7 changes: 7 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"bracketSpacing": false,
"singleQuote": true,
"printWidth": 80,
"trailingComma": "all",
"arrowParens": "avoid"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist/index.js",
},
{
"type": "node",
"request": "launch",
"name": "Run Mocha tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"runtimeArgs": [
"-r",
"${workspaceRoot}/node_modules/source-map-support/register"
],
"cwd": "${workspaceRoot}",
"autoAttachChildProcesses": true,
"args": [
"--config",
"${workspaceRoot}/.mocharc.json",
"${workspaceRoot}/dist/__tests__/**/*.js",
"-t",
"0"
]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"editor.rulers": [80],
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"editor.trimAutoWhitespace": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true
},

"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/CVS": true,
"dist": true,
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.preferences.quoteStyle": "single",
"eslint.run": "onSave",
"eslint.nodePath": "./node_modules",
"eslint.validate": [
"javascript",
"typescript"
]
}
29 changes: 29 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Watch and Compile Project",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "build:watch"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$tsc-watch"
},
{
"label": "Build, Test and Lint",
"type": "shell",
"command": "npm",
"args": ["--silent", "run", "test:dev"],
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": ["$tsc", "$eslint-compact", "$eslint-stylish"]
}
]
}
6 changes: 6 additions & 0 deletions sandbox/chat-notification-pubnub-example/facade/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@loopback/cli": {
"packageManager": "npm",
"version": "2.21.2"
}
}
Loading

0 comments on commit e6a2db0

Please sign in to comment.