diff --git a/PROVISIONING.md b/PROVISIONING.md new file mode 100644 index 0000000..f7a6771 --- /dev/null +++ b/PROVISIONING.md @@ -0,0 +1,32 @@ +# Current deployment method + +The deployment is triggered when something is pushed on [deployment](https://github.com/coderbunker/inventory-server/tree/deployment) branch using [codeship](http://codeship.com/). + +The server hosting the deployment runs the webapp using pm2 as suggested in [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04). + +pm2 uses [process.yml](https://github.com/coderbunker/inventory-server/blob/deployment/process.yml) configuration file. + +The hosting itself works with an nginx service forwarding the requests to the local web application. + + +## Codeship administration +Once you are listed in the [project owners](https://app.codeship.com/orgs/coderbunker/teams/owners) you can: +* see deployments history: [Codeship dashboard](https://app.codeship.com/projects/261737) +* manage deployment scripts [Codeship administration page](https://app.codeship.com/projects/261737/deployment_branches/187689) + + +# How to prepare the host + +#### Allow host's ssh keys to access this repository +The host needs to have read access on this reposit to download the deployment branch. + +Add the ssh keys of the new host (the content of the file: ~/.ssh/id_rsa.pub) on the "[Deploy keys section](https://github.com/coderbunker/inventory-server/settings/keys)". + +Before the first deployment, the reposit has to be downloaded and the deployment branch must be checkout. + + git clone git@github.com:coderbunker/inventory-server.git + cd inventory-server + git checkout deployment + +#### Install hosting programs +If you choose to use pm2 + nginx to monitor application, they have to be installed separately (their installation is not triggered by 'npm install'). diff --git a/README.md b/README.md index aa11e67..622ad24 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,25 @@ http://127.0.0.1:1234/ Try also http://127.0.0.1:1234/search + +## Troobleshooting. +If the application is not starting, check that if there is any application already using port 1234. +It is also possible that the previous time that "inventory-server" had been lauched did not termniate properly and it is still holding the port. + +# Other information: +The content are stored on a google spreadsheet. You need permission to edit: +https://docs.google.com/spreadsheets/d/1QHKa3vUpht7zRl_LEzl3BlUbolz3ZiL8yKHzdBL42dY/edit + +# Deployment + +## Push to deploy +The website is published on the domain name url.coderbunker.com + +The deployment is automatically triggered when something is pushed on the [deployment branch](https://github.com/coderbunker/inventory-server/tree/deployment). + + # Contribution + ## Use pull request Avoid pushing straight to the master branch any code that needs review. Please follow the following steps. @@ -43,38 +61,3 @@ Please follow the following steps. git branch -d my_branch #if you don't need that branch anymore you can delete it ## other information the project is structured around [expressjs](https://github.com/expressjs/express) -# Deploy -To deploy inventory-server you need an account a [heroku account](https://signup.heroku.com/dc?_ga=2.174119140.795848951.1511268290-1509905748.1509873833) -#### - [Install heroku](https://devcenter.heroku.com/articles/getting-started-with-python?c=70130000000NhRJAA0&utm_campaign=Onboarding-Nurture-Email-1&utm_medium=email&utm_source=nurture&utm_content=devcenter&utm_term=start-python#set-up) -#### - Once your installation succeded you can login into your account using heroku's command line: - heroku login -## Prepare your workspace -### Prepare it from scratch -#### - Clone this repository then go to the project folder - git clone https://github.com/coderbunker/inventory-server.git - cd inventory-server -#### - In order to quickly create a new deployment of this repository, create your copy repository hosted in their server: https://git.heroku.com. -You can create one with one command: -Skip this step if you want to manage our deployment. - heroku create #will add a remote repository called 'heroku'(ensure you don't have an existing remote with that name) -### Deploy the code you contributed on -#### - Clone this repository then go to the project folder - git clone https://github.com/coderbunker/inventory-server.git - cd inventory-server -#### - In order to administrate our release you can run the following commands (requires access rights). - git remote add heroku https://git.heroku.com/enigmatic-brushlands-32514.git - -### Create a separate repository that tracks the deployment -#### - Or, if you want to work in a dedicated repository you can do this that way - heroku git:clone -a enigmatic-brushlands-32514 - cd enigmatic-brushlands-32514 - -## Release your work -#### - Push the version of the repository you want to deploy on the 'heroku' remote, for instance if you want to deploy your master branch type: - git push heroku master - #No matter the local branch you are pushing, it is recommended to push on heroku remote's master branch - git push heroku my_branch:master #only if you are using a different branch -#### - Finally just deploy the app you just pushed using this command. - heroku ps:scale web=1 - -Et voilĂ  \ No newline at end of file diff --git a/package.json b/package.json index 32b1a89..445554d 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "eslint": "^4.6.1", "eslint-config-airbnb-base": "^12.0.0", "eslint-plugin-import": "^2.7.0", + "pm2": "^2.9.3", "pre-commit": "^1.2.2" } } diff --git a/process.yml b/process.yml new file mode 100644 index 0000000..7fb5825 --- /dev/null +++ b/process.yml @@ -0,0 +1,7 @@ +apps: + - script : app.js + instances: 1 + exec_mode: cluster + name: inventory-server + env: + PORT: 8080