diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..4afcf70 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2019 Rendered Text + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 01c23d4..1d99c90 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,42 @@ # Semaphore demo CI/CD pipeline using Node.js -Example application and CI/CD pipeline showing how to run a JavaScript project -on Semaphore 2.0. Project consists of a Node.js server based on Nest.js. -The code is written in TypeScript. +Example application and CI/CD pipeline showing how to run a Node.js project +on Semaphore 2.0. + +The application is based on Nest.js. The code is written in TypeScript. ## CI/CD on Semaphore -Fork this repository and use it to +1. Fork this repository and use it to [create a project](https://docs.semaphoreci.com/article/63-your-first-project). +2. Create a project on Google Cloud: `semaphore-demo-nodejs-k8s` +3. Create Kubernetes cluster on Google Cloud: `semaphore-demo-nodejs-k8s-server` +4. Create PostgreSQL db on Google Cloud. +5. Create database `demo` and user `demouser`. +6. Copy environment files and edit db hostname and db password: + ```bash + $ cp ormconfig.sample.json /tmp/ormconfig.production.json + $ cp sample.env /tmp/production.env + ``` +7. Upload environment files as a secret: + + ```bash + $ sem create secret production-env \ + -f /tmp/ormconfig.production.json:/home/semaphore/ormconfig.production.json \ + -f /tmp/production.env:/home/semaphore/production.env + ``` + +8. Create Service Account in IAM: + - Role: project owner + - Create and download access key JSON file. +9. Upload Access Key to Semaphore as a secret: + ```bash + $ sem create secret gcr-secret \ + -e GCP_PROJECT_ID=semaphore-demo-nodejs-k8s \ + -e GCP_PROJECT_DEFAULT_ZONE=YOUR_REGION_AND_ZONE \ + -f PATH_TO_YOUR_ACCESS_KEY_FILE.json:/home/semaphore/.secrets.gcp.json + ``` +10. Push changes to get workflow started. The CI pipeline will look like this: diff --git a/development.env b/development.env new file mode 100644 index 0000000..fa66522 --- /dev/null +++ b/development.env @@ -0,0 +1,8 @@ +NODE_ENV=development +PORT=3001 +DATABASE_TYPE=postgres +DATABASE_HOST=localhost +DATABASE_USER=demouser +DATABASE_PASSWORD=qwerty +DATABASE_DBNAME=demo +DATABASE_PORT=5432 \ No newline at end of file