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
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7.9-alpine

COPY /app /app
COPY requirements.txt /app
WORKDIR /app
COPY requirements.txt /app
RUN pip install -r requirements.txt

COPY /app /app

#ENV FLASK_APP main.py

#ENV FLASK_RUN_HOST 0.0.0.0
Expand Down
31 changes: 31 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"

[packages]
click = "==7.1.2"
dnspython = "==2.0.0"
flask-mongoengine = "==0.9.5"
itsdangerous = "==1.1.0"
mongoengine = "==0.20.0"
pymongo = "==3.11.0"
six = "==1.15.0"
Flask = "==1.1.2"
Flask-Login = "==0.5.0"
Flask-PyMongo = "==2.3.0"
Flask-WTF = "==0.14.3"
Jinja2 = "==2.11.2"
MarkupSafe = "==1.1.1"
Werkzeug = "==1.0.1"
WTForms = "==2.3.3"

[requires]
python_version = "3.8"

[scripts]
server = "flask run"
tests = "nosetests"
304 changes: 304 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from flask_login import LoginManager, UserMixin, current_user, login_user, logout_user
from flask import Flask, render_template, request, flash, redirect, url_for
from flask_mongoengine import MongoEngine, Document
from secret import *
import secret



app = Flask(__name__)
app.secret_key = app_secret_key
app.secret_key = secret.app_secret_key
app.config['MONGODB_SETTINGS'] = {
'db': DB_name,
'host': DB_link
'db': secret.DB_name,
'host': secret.DB_link
}

db = MongoEngine(app)
Expand Down
2 changes: 1 addition & 1 deletion app/objects/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class User(UserMixin, db.Document):
meta = {'collection': DB_collection_users}
meta = {'collection': 'users'}
name = db.StringField(required=True)
login = db.StringField(unique=True, required=True)
email = db.StringField(unique=True, required=True)
Expand Down
4 changes: 1 addition & 3 deletions app/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

app_secret_key = os.environ.get('app_secret_key', None)
DB_link = os.environ.get('DB_link', None)
DB_name = os.environ.get('DB_name', None)
DB_collection_users = os.environ.get('DB_collection_users', None)
DB_collection_works = os.environ.get('DB_collection_works', None)
DB_name = os.environ.get('DB_name', None)
19 changes: 16 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
version: '3'
services:

server:
build:
context: .
dockerfile: server.dockerfile
context: .
dockerfile: server.dockerfile
env_file: ./.env
ports:
- "5000:5000"
- "5000:5000"
depends_on:
- mongo
mongo:
image: mongo
ports:
- 27017:27017
volumes:
- db_data:/data/db

volumes:
db_data:
24 changes: 24 additions & 0 deletions linkedinSearch.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"folders": [
{
"name": "Configs (Root)",
"path": "."
},
{
"name": "App",
"path": "app"
},
],
"settings": {
"files.exclude": {
"**/.git": true,
},
"editor.tabSize": 4,
},
"extensions": {
"recommendations": [
"ms-azuretools.vscode-docker",
"mhutchie.git-graph",
]
}
}
28 changes: 19 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ app_secret_key="test"
DB_link = "Atlas URL"
DB_name = "test"
```
LETS USE PIPENV

- Run in CMD/Terminal `pip install pipenv`
- pipenv shell
- pipenv install ()


- Run in CMD/Terminal `pip install virtualenv`
- Create virtualenv with:
- Windows -> `virtualenv venv --python=python`
Expand All @@ -29,15 +36,18 @@ DB_name = "test"
- Open `http://localhost:5000/`
------------

### Run with Docker: ###

- Install Docker
- Run `docker build -t server . -f server.dockerfile`
- Run `docker run -d -p 5000:5000 server `
- Open `http://localhost:5000/`
------------
### Run with Docker-compose: ###
- Install Docker
- Run `docker-compose up`
- Run `docker-compose up --build`
- NOTE --build flag may be removed if there is no need to rebuild container
- Open `http://localhost:5000/`
------------
------------

### Run only DB container

`docker-compose up -d mongo`

To run all in containers - change .env file connection string to:
`mongodb://mongo:27017`

`server = "gunicorn -b=0.0.0.0:8443 -w=4 bot.app:app"`
5 changes: 3 additions & 2 deletions server.dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7.9-alpine

COPY /app /app
COPY requirements.txt /app
WORKDIR /app
COPY requirements.txt /app
RUN pip install -r requirements.txt

COPY /app /app

ENV FLASK_APP main.py

ENV FLASK_RUN_HOST 0.0.0.0
Expand Down