Skip to content

Commit

Permalink
Merge pull request #46 from OSSHealth/dev
Browse files Browse the repository at this point in the history
Docker support
  • Loading branch information
howderek committed May 11, 2017
2 parents c417d3a + da6d901 commit 62cd225
Show file tree
Hide file tree
Showing 35 changed files with 4,246 additions and 1,380 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*.sqlite
*.ini
*.cfg
*.cfg.old

# OS generated files #
######################
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3

RUN mkdir /ghdata
WORKDIR /ghdata
ADD . /ghdata
RUN pip install --upgrade .

CMD ["ghdata"]
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ default:
\e[1mrun-debug \e[0m Runs GHData in development mode\n\
\e[1mpython-docs \e[0m Generates new Sphinx documentation\n\
\e[1mapi-docs \e[0m Generates new apidocjs documentation\n\
\e[1mdocs \e[0m Generates all documentation\n"
\e[1mdocs \e[0m Generates all documentation\n\
\e[1mupdate-deps \e[0m Generates updated requirements.txt\n"

install:
sudo pip2 install --upgrade . && pip3 install --upgrade .
Expand All @@ -27,7 +28,7 @@ python-docs:
&& rm -rf _build \
&& make html

api-docs:l
api-docs:
apidoc -i ghdata/ -o docs/api/

docs: api-docs python-docs
Expand All @@ -49,4 +50,8 @@ endif

test: check-test-env
python2 -m pytest
python3 -m pytest
python3 -m pytest

update-deps:
@ hash pipreqs 2>/dev/null || { echo "This command needs pipreqs, installing..."; pip install pipreqs; exit 1; }
pipreqs ./
82 changes: 27 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,59 @@
# GHData

branch | status
--- | ---
--- | ---
master | [![Build Status](https://travis-ci.org/OSSHealth/ghdata.svg?branch=master)](https://travis-ci.org/OSSHealth/ghdata)
dev | [![Build Status](https://travis-ci.org/OSSHealth/ghdata.svg?branch=dev)](https://travis-ci.org/OSSHealth/ghdata)
dev | [![Build Status](https://travis-ci.org/OSSHealth/ghdata.svg?branch=dev)](https://travis-ci.org/OSSHealth/ghdata)

GHData is a Python library and REST server that provides data related to GitHub repositories. Hosting the GHData project requires a copy of the [GHTorrent database](http://ghtorrent.org/downloads.html).

GHData is under heavy development; expect frequent backwards-incompatible changes until a 1.x.x release!



Roadmap
-------

Our technical, outreach, and academic goals [roadmap](https://github.com/OSSHealth/ghdata/wiki/Release-Schedule).


License and Copyright
---------------------

Copyright © 2017 University of Nebraska at Omaha and the University of Missouri
Installation with Docker
------------------------
1. Clone the repo
2. `docker-compose build`
3. `docker-compose up`

GHData is free software: you can redistribute it and/or modify it under the terms of the MIT License as published by the Open Source Initiative. See the file LICENSE for more details.

All associated documentation is licensed under the terms of the Creative Commons Attribution Share-Alike 4.0 license. See the file CC-BY-SA-4.0 for more details.


Dependencies
------------

Installation without Docker
---------------------------
### Dependencies
- Python 3.4.x and `pip`
- MySQL 5.x or later with the [GHTorrent database](http://ghtorrent.org/) [MSR14 dataset](http://ghtorrent.org/) for testing
- [Installation instructions](https://github.com/gousiosg/github-mirror/tree/master/sql)

Installation
------------

First, install ghdata

- Stable: `pip install --upgrade https://github.com/OSSHealth/ghdata/archive/master.zip`
- Development: `git clone -b dev https://github.com/OSSHealth/ghdata/ && pip install --upgrade ./ghdata/`

Then, run `ghdata` to create a new config file. Edit the generated `ghdata.cfg` file with your database settings.
- MySQL 5.x or later with the [GHTorrent database](http://ghtorrent.org/)
- You can use the [MSR14 dataset](http://ghtorrent.org/msr14.html) for testing
- [Installation instructions](https://github.com/gousiosg/github-mirror/tree/master/sql)

Run `ghdata` again. For development, use `make run-debug`, that will start the server with Werkzeug's debugging on.
After restoring GHTorrent (or msr14) to MySQL, it is recommended you create a user for GHData. GHData only needs `SELECT` privileges.

Usage
-----

To run GHData as a server:
1. Type `ghdata` in a terminal. A config file named ghdata.cfg will be generated.
2. Edit the ghdata.cfg file with your database settings.
3. Type `ghdata` again to start the server.


To use as a Python package:
```python
from ghdata import GHData

client = GHData('mysql+pymysql://<user>:<pass>@<host>:<port>/<database name>')
railsID = client.repoid(owner='rails', repo='rails')
railsStars = client.stargazers(railsID)
Once the database is set up, clone GHData
```bash
git clone https://github.com/OSSHealth/ghdata/
cd ghdata && pip install -U .
```

Uninstall
------------
To uninstall, run `pip uninstall ghdata`


TODO: More/Better API documentation
Run `ghdata` to create the configuration file (ghdata.cfg). Edit the file to reflect your database credentials.

DFD Descritpion of GHData
---------------------------------------
Move ./ghdata/ghdata/static/ to a static host on the same domain. If you would like GHData to serve the files itself, set the "developer" flag to 1 in ghdata.cfg. *`ghdata` must be run in the base of the repo if it is serving the static files*

DFD Image Here
Run `ghdata` to start the backend.


History
-------


Maintainers
-----------
License and Copyright
---------------------
Copyright © 2017 University of Nebraska at Omaha and the University of Missouri

GHData is free software: you can redistribute it and/or modify it under the terms of the MIT License as published by the Open Source Initiative. See the file LICENSE for more details.

(This work has been funded through the Alfred P. Sloan Foundation)

46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: '3'
services:

db:
build: ./docker/database
restart: always
command: mysqld --verbose
volumes:
- /var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_BASE: "msr14"
MYSQL_USER: "msr14"
MYSQL_PASSWORD: "password"
MYSQL_ROOT_PASSWORD: "root"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"

ghdata:
build: .
restart: always
volumes:
- .:/ghdata
ports:
- "5000:5000"
links:
- db
depends_on:
- db
environment:
GHDATA_DB_USER: "root"
GHDATA_DB_PASS: "root"
GHDATA_DB_PORT: "3306"
GHDATA_DB_HOST: "db"
GHDATA_DB_NAME: "msr14"
GHDATA_GITHUB_API_KEY:
GHDATA_PUBLIC_WWW_API_KEY:
GHDATA_HOST:
GHDATA_PORT:

web:
build:
context: ./
dockerfile: ./docker/static-web/Dockerfile
ports:
- "80:80"
18 changes: 18 additions & 0 deletions docker/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mariadb:10

RUN mkdir /data
WORKDIR /data

# Download database dump
RUN apt-get update && apt-get install -y curl && \
curl -O https://ghtstorage.blob.core.windows.net/downloads/msr14-mysql.gz

# Configure it to work with the database we will create
RUN echo 'CREATE DATABASE msr14; USE msr14;' > 02-msr14-mysql.sql && \
gunzip -c msr14-mysql.gz >> 02-msr14-mysql.sql && \
mv 02-msr14-mysql.sql /docker-entrypoint-initdb.d/msr-mysql.sql

EXPOSE 3306

# Run the database
CMD ["/usr/bin/mysqld"]
3 changes: 3 additions & 0 deletions docker/static-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM kyma/docker-nginx
COPY ./ghdata/static /var/www
CMD 'nginx'
1 change: 1 addition & 0 deletions docker/static-web/www

0 comments on commit 62cd225

Please sign in to comment.