Browse Source

Dockerfile added and readme updated (#40)

Added a docker-compose script for running and updated readme file. Closes (#14, #35)
master
Kevin Assogba 4 years ago
committed by GitHub
parent
commit
3dfe4404ef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 109 additions and 11 deletions
  1. +27
    -0
      Dockerfile
  2. +71
    -11
      README.md
  3. +11
    -0
      docker-compose.yml

+ 27
- 0
Dockerfile View File

@ -0,0 +1,27 @@
FROM ubuntu
LABEL maintainer="Jeffery Russell"
# install all dependencies
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y build-essential && \
apt-get install -y sudo curl && \
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - && \
apt-get install -y nodejs && \
apt-get update && \
apt-get clean
# Create a working directory for the container
RUN mkdir /github-graphs
# copy files from the directory of the Dockerfile to the docker container
COPY /server /github-graphs/server
COPY README.md /github-graphs/
COPY LICENSE /github-graphs/
# setup working directory to the default in the container
WORKDIR /github-graphs/server
# Install dependencies and start the program at RUN
RUN npm install
CMD ["node", "server.js"]

+ 71
- 11
README.md View File

@ -16,7 +16,8 @@ If you are lucky, you can find the site live [here](https://github-graphs.com/).
![javascript](./doc/javaScript.jpg) ![javascript](./doc/javaScript.jpg)
## Native Deployment
## Deployment
The easiest way to get started with Github-Graphs is to fork this repository The easiest way to get started with Github-Graphs is to fork this repository
and follow the instructions below. and follow the instructions below.
@ -25,13 +26,13 @@ and follow the instructions below.
The objective of creating an app under your github account is to access an The objective of creating an app under your github account is to access an
endpoint through the GitHub API and obtain credentials to set your environment endpoint through the GitHub API and obtain credentials to set your environment
file. For directives on how to create a new OAuth app, consult the corresponding
file. For more information on how to create a new OAuth app, consult the corresponding
Github developer documentation [here](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/). Github developer documentation [here](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/).
#### Create a .env file #### Create a .env file
Setup your environment credentials by creating a `.env file` inside the folder
`/server` with the code below filled in.
After forking this repository, run the command `cd server/`. Inside that folder,
setup your environment credentials by creating a `.env file` with the code below filled in.
``` ```
CLIENT_ID = <your_client_ID_from_oauth_app> CLIENT_ID = <your_client_ID_from_oauth_app>
@ -40,34 +41,91 @@ SESSION_SECRET =
PORT = <any_number> PORT = <any_number>
``` ```
The creation of your OAuth app and the .env file are required steps,
irrespective of your desired deployment environment. For specific directions,
continue by following the steps specified below.
### Deployment on the local machine
#### Install dependencies #### Install dependencies
Dependencies are installed using `npm`. Therefore, please install the package manager Dependencies are installed using `npm`. Therefore, please install the package manager
before proceeding. If you already have `npm` installed, run the command below inside before proceeding. If you already have `npm` installed, run the command below inside
`/server` in order to install the dependencies in the package directory.
`server/` in order to install the dependencies in the package directory.
```bash ```bash
npm install npm install
``` ```
#### Activate GitHub-Graphs
#### Explore GitHub-Graphs
Inside `/server`, run the following command to start the program, and in your
Inside `server/`, run the following command to start the program, and in your
browser, check `localhost:8000` to visualize your Github network. browser, check `localhost:8000` to visualize your Github network.
```bash ```bash
node server.js node server.js
``` ```
### Deployment in a Docker container
Github-graphs can also be deployed inside a docker container and displayed in
your browser through port mapping. To get started run the following commands
inside your forked repository.
The easiest way to deploy in a docker container is through the use of our proposed
`docker-compose.yml` file. If you choose this methodology, make sure the port numbers
in your `.env` file matches the docker-compose file. Note that this approach will work
only on systems which have Docker and Docker-compose both installed.
Considering the example provided in our provided docker-compose,
the port number of the .env file should be `PORT= 8000`. Therefore, you could
visualize the Github-Graphs page at `localhost:8080` after running:
```
docker-compose up -d --build
```
In order to clean the environment, you can run the following command.
```
docker-compose down --rmi all
```
Besides the use of docker-compose, deployment with just docker is possible with the following commands:\
```
docker build -t <choose_name_for_image> .
docker run -d --name <choose_name_for_container> -p <local_port_num>:<port_num_from_env_file> <name_of_image>
```
For instance, assume I name my image `graph-app`, my container `github-graphs`,
and set the port number in my .env file to `8000`, I can decide to listen on my localhost at port `8080`.
Therefore, my commands are:
```
docker build -t graph-app .
docker run -d --name github-graphs -p 8080:8000 graph-app
```
If you are willing to read the debugging statement on the CLI, do not add `-d` to the `docker run` statement.
At this step, you can now visualize Github graphs at `localhost:<local_port_num>`.
## Contributing ## Contributing
We are very open to new contributors. If you want to contribute to this project, and don't know where to start, look at the [open issues](https://github.com/jrtechs/github-graphs/issues). Once you know what you want to work on, comment on the issue and file a pull request.
We are very open to new contributors. If you want to contribute to this project,
and don't know where to start, look at the [open issues](https://github.com/jrtechs/github-graphs/issues).
Once you know what you want to work on, comment on the issue and file a pull request.
## API Reference ## API Reference
`GET https://github-graphs.com/api/friends/<username>` `GET https://github-graphs.com/api/friends/<username>`
Fetches `https://api.github.com/users/<username>/followers` [(GitHub Reference)](https://developer.github.com/v3/users/followers/#list-followers-of-a-user) and `https://api.github.com/users/<username>/following` [(GitHub Reference)](https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user) to generate an array of users following `<username>` and that `<username>` follows each with values `login` and `avatar_url`.
Fetches `https://api.github.com/users/<username>/followers` [(GitHub Reference)](https://developer.github.com/v3/users/followers/#list-followers-of-a-user)
and `https://api.github.com/users/<username>/following` [(GitHub Reference)](https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user)
to generate an array of users following `<username>` and that `<username>` follows each with values `login` and `avatar_url`.
Example result: Example result:
@ -115,7 +173,8 @@ Example result:
`GET https://github-graphs.com/api/org/users/<organization_name>` `GET https://github-graphs.com/api/org/users/<organization_name>`
Fetches `https://api.github.com/orgs/<organization_name>/members` [(GitHub Reference)](https://developer.github.com/v3/orgs/members/#members-list) to generate an array of users that are in `<organization_name>` each with values `login` and `avatar_url`.
Fetches `https://api.github.com/orgs/<organization_name>/members` [(GitHub Reference)](https://developer.github.com/v3/orgs/members/#members-list)
to generate an array of users that are in `<organization_name>` each with values `login` and `avatar_url`.
Example result: Example result:
@ -132,7 +191,8 @@ Example result:
`GET https://github-graphs.com/api/org/repositories/<organization_name>` `GET https://github-graphs.com/api/org/repositories/<organization_name>`
Fetches `https://api.github.com/orgs/<organization_name>/repos` [(GitHub Reference)](https://developer.github.com/v3/repos/#list-organization-repositories) to return an array of repositories `<organization_name>` owns.
Fetches `https://api.github.com/orgs/<organization_name>/repos` [(GitHub Reference)](https://developer.github.com/v3/repos/#list-organization-repositories)
to return an array of repositories `<organization_name>` owns.
Example result: Example result:

+ 11
- 0
docker-compose.yml View File

@ -0,0 +1,11 @@
version: '3.7'
services:
github-graphs:
build:
dockerfile: Dockerfile
image: graph-app:latest
container_name: github-graphs
ports:
- "8080:8000"

Loading…
Cancel
Save