Skip to content
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
15 changes: 15 additions & 0 deletions notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:latest

MAINTAINER Prashant Shahi "prashantshahi567@gmail.com"

RUN apt-get update -y && \
apt-get install -y python-pip python-dev build-essential

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt

ENTRYPOINT ["python"]

CMD ["run.py"]
14 changes: 14 additions & 0 deletions notebook/INSTALL.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Building Docker Image for Flask App using the Dockerfile (using Ubuntu:latest)
docker build -t flaskapp:latest .

# Downloading Light MongoDB container and building the image
docker pull mvertes/alpine-mongo

# Making Containers of MongoDB Client Docker Image
docker run -d -p 27017:27017 --name mongoclient mvertes/alpine-mongo

# Making Container of FlaskApp Docker Image and linking to Mongoclient Container
docker run -d -p 5000:5000 --link mongoclient --name flaskapp flaskapp:latest

echo " * Notebook FlaskApp should be live at http://localhost:5000/"
25 changes: 21 additions & 4 deletions notebook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,31 @@ These instructions will get you a copy of the project up and running on your loc

### Pre-requisites

1. [Flask](http://flask.pocoo.org/docs/1.0/installation/)
2. [MongoDB](https://docs.mongodb.com/manual/installation/)
1. [Flask](http://flask.pocoo.org/)
2. [MongoDB](https://docs.mongodb.com/)
3. [Docker](https://docs.docker.com/install/)

### Installation

```
git clone the repository

cd into the repository/notebook
python run.py

chmod +x *.sh

./INSTALL.sh
```
Visit `localhost:5000` on your browser

### Run FlaskApp

Note: Except for the first time

`./START.sh`

### Terminate FlaskApp

`./STOP.sh`


Visit `localhost:5000` on your browser
7 changes: 7 additions & 0 deletions notebook/START.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Start MongoDB Client Docker Container
docker start mongoclient

# Start FlaskApp Container
docker start flaskapp

echo " * Notebook FlaskApp should be started at http://localhost:5000/ "
7 changes: 7 additions & 0 deletions notebook/STOP.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Start MongoDB Client Docker Container
docker stop mongoclient

# Start FlaskApp Container
docker stop flaskapp

echo " * Notebook FlaskApp should be stopped "
3 changes: 3 additions & 0 deletions notebook/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FLASK==1.0.2
BSON
PYMONGO
5 changes: 4 additions & 1 deletion notebook/run.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import os
from flask import Flask, flash, render_template, redirect, request
from bson.objectid import ObjectId
from datetime import datetime
from pymongo import MongoClient

app = Flask(__name__)
client = MongoClient('mongodb://localhost:27017/')
client = MongoClient(os.environ['MONGOCLIENT_PORT_27017_TCP_ADDR'],27017)
db = client.todo


@app.route('/')
@app.route('/note', methods=['GET'])
def get_notes():
notes = []
Expand Down