Skip to content

Commit

Permalink
fix(#718): Installation documentation for using One Platform (#728)
Browse files Browse the repository at this point in the history
* fix(#718): Added README and Lerna in scripts

* fix(#718): Added platform.js to copy all the .env.example files to .env file

* fix(#718): Added script to post-install
  • Loading branch information
hybridx authored Oct 5, 2020
1 parent f823298 commit 14c2d5f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,38 @@ An integrated application hosting platform which allows you to host your SPAs. I
- Notifications Framework
- Feedback Framework

## Install
### Prerequisites

- Docker [Download](https://www.docker.com/get-started)

## Installation

### Install node_modules for all the packages
#### PS: The below script also copies `.env.example` to `.env` for all the services
```sh
npm install
# OR
lerna bootstrap
```

### Environment Config

Copy all the `.env.example` to `.env` and add the following fields

- For SPAs (packages ending with *-spa)
1. Add API_URL and set the url to .env

- For services (packages ending with *-service)
1. Add database path in DB_PATH
2. Add database name in DB_NAME
3. Add database username in DB_USER
4. Add database password in DB_PASSWORD

#### Example
```properties
## Database
DB_PATH=localhost
DB_NAME=platform
DB_USER=admin
DB_PASSWORD=admin
```

## Using docker-compose for local development
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
},
"homepage": "https://github.com/1-Platform/one-platform#readme",
"scripts": {
"lerna": "lerna",
"test": "echo \"Error: no test specified\" && exit 1",
"cli-microservice": "sh cli-init.sh",
"deploy": "sh deploy.sh"
"deploy": "sh deploy.sh",
"postinstall": "npm run lerna bootstrap && node platform.js"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "4.3.0",
Expand Down
14 changes: 14 additions & 0 deletions platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
console.log( 'Copying .env.example to .env for the services: Started' );
const fs = require( 'fs' );
const path = require( 'path' );
const { COPYFILE_EXCL } = fs.constants;
const dir = 'packages';
fs.readdir( dir, (err, list) => {
const services = list.filter( folder => folder.endsWith( '-service' ) );
services.forEach(service => {
const pathToEnv = dir + '/' + service + '/';
fs.copyFile( pathToEnv + '.env.example', pathToEnv + '.env', COPYFILE_EXCL, ( error ) => error );
path.dirname( service );
})
} );
console.log( 'Copying .env.example to .env for the services: Completed' );

0 comments on commit 14c2d5f

Please sign in to comment.