Skip to content

Commit

Permalink
add .dockerignore and .editorconfig (fossasia#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaveshAn authored and niranjan94 committed Oct 16, 2017
1 parent 3a6e85a commit 2ec4259
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 26 deletions.
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
.dockerignore

#####################
# .gitignore copied
#####################

.cache/*
__pycache__/*
node_modules/*
.coverage
.idea/*
*.pyc
*.py.bak
*.swp
app/static/bower_components/
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.html]
indent_size = 4

[*.js]
indent_size = 4

[*.css]
indent_size = 4
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,15 @@ A sample query : `/api/v1/search/bing?query=fossasia&format=xml&num=10`

## Installation

Make sure you have [Nodejs](https://nodejs.org/en/) installed.
Running this tool requires installing the nodejs as well as python dependencies.

```
git clone https://github.com/fossasia/query-server.git
cd query-server
npm install -g bower
bower install
pip install -r requirements.txt
```

To set up MongoDB on your server :
```bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
```

## Usage

To run the query server:
```bash
python app/server.py
```
1. [Local Installation](/docs/installation/local.md)

2. [Deployment on Heroku](/docs/installation/heroku.md)

3. [Deployment with Docker](/docs/installation/docker.md)

One-click Docker and Heroku deployment is also available:

[![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/fossasia/query-server) [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/fossasia/query-server)

## Contribute

Expand Down
20 changes: 20 additions & 0 deletions docs/installation/docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Docker

[![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/fossasia/query-server)

* Get the latest version of docker. See the [offical site](https://docs.docker.com/engine/installation/) for installation info for your platform.

* Install the latest version of docker-compose. Windows and Mac users should have docker-compose by default as it is part of Docker toolbox. For Linux users, see the
[official guide](https://docs.docker.com/compose/install/).

* Run `docker` and in terminal to see if they are properly installed.

* Clone the project and cd into it.

```bash
git clone https://github.com/fossasia/query-server.git && cd query-server
```

* In the terminal window, run `docker build -t query-server:latest` to build badgeyay's docker image. This process can take some time.

* After build is done, run `docker run -d -p 7001:7001 query-server` to start the server.
30 changes: 30 additions & 0 deletions docs/installation/heroku.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Heroku

One-click Heroku deployment is available:

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/fossasia/query-server)

### Steps for Manual Deployment

* We need to install heroku on our machine. Type the following in your linux terminal:
* ```wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh```
This installs the Heroku Toolbelt on your machine to access heroku from the command line.
* Next we need to login to our heroku server (assuming that you have already created an account). Type the following in the terminal:
* ```heroku login```
* Enter your credentials and login.
* Once logged in we need to create a space on the heroku server for our application. This is done with the following command
* ```heroku create```
* Add nodejs build pack to the app
* ```heroku buildpacks:add --index 1 heroku/nodejs```
* Add python build pack to the app
* ```heroku buildpacks:add --index 2 heroku/python```
* Check nodejs and python build pack in the app
* ```heroku buildpacks```
It should return

> 1. heroku/nodejs
> 2. heroku/python
* Then we deploy the code to heroku.
* ```git push heroku master``` or
* ```git push heroku yourbranch:master``` if you are in a different branch than master
70 changes: 70 additions & 0 deletions docs/installation/local.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Local Development Setup

The instructions on this page will guide you in setting up a local development environment in your system.

For a start, fork Query-Server to your own github account. Then, clone it to your local system.

```sh
git clone -b master https://github.com/<your_username>/query-server.git
```

Add an upstream remote so that you can push your patched branches for starting a PR .

```sh
cd query-server
git remote add upstream https://github.com/fossasia/query-server.git
```

Make sure you have [Nodejs](https://nodejs.org/en/) installed.
Running this tool requires installing the nodejs as well as python dependencies.

```
npm install -g bower
bower install
pip install -r requirements.txt
```

To set up MongoDB on your server :

```bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
```

To run the project on a local machine.

```sh
python app/server.py
```

## Preferred Development Workflow

1. Get the latest copy of code from upstream.

```sh
git pull upstream master
```

2. Once you get assigned an issue, create a new branch from `master`.

```sh
git checkout -b XXX-mock-issue # XXX is the issue number
```

3. Work on your patch, test it and when it's done, push it to your fork.

```sh
git push origin XXX-mock-issue
```

4. File a PR and wait for the maintainers to suggest reviews or in the best case
merge the PR. Then just update `master` of your local clone.

```sh
git pull upstream master
```

And then loop back again. For contribution guidelines, refer [here](https://github.com/fossasia/query-server/blob/master/.github/CONTRIBUTING.md)

0 comments on commit 2ec4259

Please sign in to comment.