Skip to content

Deployment install #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions PROVISIONING.md
Original file line number Diff line number Diff line change
@@ -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').
53 changes: 18 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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à
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
7 changes: 7 additions & 0 deletions process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apps:
- script : app.js
instances: 1
exec_mode: cluster
name: inventory-server
env:
PORT: 8080