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
29 changes: 29 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM python:3.11-slim-buster


ENV PYTHONDONTWRITEBYTECODE=1

ENV PYTHONUNBUFFERED=1

ENV PYDEVD_DISABLE_FILE_VALIDATION=1

WORKDIR /app

COPY Pipfile Pipfile.lock ./

RUN python -m pip install --upgrade pip

RUN pip install flask-migrate

RUN pip install --no-cache-dir pipenv

RUN pipenv install --dev --system --deploy --clear

RUN pip uninstall pipenv -y

RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y

COPY . ./

CMD [ "python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "-m", "flask", "run", "--host=0.0.0.0" ]

101 changes: 101 additions & 0 deletions backend/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
alembic = "==1.9.4"
aniso8601 = "==8.0.0"
asgiref = "==3.6.0"
attrs = "==22.2.0"
bcrypt = "==3.1.7"
bidict = "==0.22.1"
blinker = "==1.5"
boto3 = "==1.26.91"
botocore = "==1.29.91"
caer = "==2.0.8"
certifi = "==2022.12.7"
cffi = "==1.15.1"
charset-normalizer = "==3.0.1"
click = "==7.1.2"
config = "==0.5.1"
contourpy = "==1.0.7"
cryptography = "==39.0.2"
cycler = "==0.11.0"
datetime = "==5.1"
depthai = "*"
distlib = "==0.3.6"
exceptiongroup = "==1.1.0"
filelock = "==3.9.0"
flask = "==1.1.2"
flask-bcrypt = "==1.0.1"
flask-cors = "==3.0.10"
flask-mail = "==0.9.1"
flask-migrate = "==4.0.4"
flask-restful = "==0.3.9"
flask-socketio = "==5.3.3"
flask-sqlalchemy = "==2.4.3"
fonttools = "==4.38.0"
gevent = "==22.10.2"
greenlet = "==2.0.2"
idna = "==3.4"
imutils = "==0.5.4"
iniconfig = "==2.0.0"
itsdangerous = "==1.1.0"
jinja2 = "==2.11.2"
jmespath = "==1.0.1"
joblib = "==1.2.0"
kiwisolver = "==1.4.4"
mako = "==1.2.4"
markupsafe = "==1.1.1"
mypy = "==0.991"
mypy-extensions = "==0.4.3"
packaging = "==23.0"
pbr = "==5.11.1"
pillow = "==9.4.0"
platformdirs = "==2.6.2"
pluggy = "==1.0.0"
protobuf = "==4.21.12"
pyignite = "==0.6.1"
pyjwt = "==2.6.0"
pylogix = "==0.8.7"
pyparsing = "==3.0.9"
pytest = "==7.2.2"
python-dateutil = "==2.8.2"
python-dotenv = "==1.0.0"
python-engineio = "==4.4.0"
python-http-client = "==3.3.7"
pytz = "==2020.1"
requests = "==2.28.2"
sendgrid = "==6.8.0"
six = "==1.15.0"
smtpapi = "==0.3.1"
sqlalchemy = "==1.3.18"
sqlparse = "==0.4.3"
starkbank-ecdsa = "==2.2.0"
stevedore = "==4.1.1"
threadpoolctl = "==3.1.0"
tomli = "==2.0.1"
twilio = "==7.17.0"
typing-extensions = "==4.4.0"
urllib3 = "==1.26.14"
websocket = "==0.2.1"
werkzeug = "==1.0.1"
"zope.event" = "==4.6"
"zope.interface" = "==6.0"
flask-login = "==0.4.1"
oauthlib = "==3.0.1"
pyopenssl = "*"
marshmallow = "==3.19.0"
psycopg2-binary = "*"
flask-pymongo = "*"
pipenv = "*"
pip = "*"
opencv-python = "*"
keyboard = "==0.13.5"

[dev-packages]
debugpy = "==1.6.7"

[requires]
python_version = "3.11"
3,125 changes: 3,125 additions & 0 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from helper_functions.run_all_cameras import run_all_cameras
from helper_functions.insert_users import mongo_db, users_collection # mongodb connection
from imageCalibrationClass import Recalibration, createPipeline
from getenv import mysql_username, mysql_password, mysql_host, mysql_port, mysql_db_name
from getenv import psql_db_name, psql_host, psql_password, psql_username, psql_port

# read in the params.json file
with open(r'params.json') as f:
Expand All @@ -39,11 +39,10 @@

# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///instances/martinrea.db'
# database configuration
app.config['SQLALCHEMY_DATABASE_URI'] = f'mysql://{mysql_username}:{mysql_password}@{mysql_host}:{mysql_port}/{mysql_db_name}'
app.config['SQLALCHEMY_DATABASE_URI'] = f'postgres://{psql_username}:{psql_password}@{psql_host}:{psql_port}/{psql_db_name}'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
# engine = create_engine('sqlite:///instances/martinrea.db')
engine = create_engine(f'mysql://{mysql_username}:{mysql_password}@{mysql_host}:{mysql_port}/{mysql_db_name}')
app.config['SERVER_NAME'] = '127.0.0.1:5000'
engine = create_engine(f'postgres://{psql_username}:{psql_password}@{psql_host}:{psql_port}/{psql_db_name}')
app.config['APPLICATION_ROOT'] = '/'
app.config['PREFERRED_URL_SCHEME'] = 'http'
app.config['CORS_HEADERS'] = 'Content-Type'
Expand Down
37 changes: 37 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
services:
backend:
container_name: martinrea_server
build:
context: .
dockerfile: Dockerfile
image: martinrea-server
depends_on:
db:
condition: service_healthy
ports:
- 8080:5000
- 5678:5678
volumes:
- .:/app

db:
container_name: martinrea_db
image: postgres
restart: always
user: postgres
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
expose:
- 5432
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5

volumes:
db-data:
10 changes: 5 additions & 5 deletions backend/getenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
mongodb_password = os.getenv('MONGO_DB_PASSWORD')

# getting mysql connection credentials
mysql_username = os.getenv('MYSQL_DB_USERNAME')
mysql_password = os.getenv('MYSQL_DB_PASSWORD')
mysql_host = os.getenv('MYSQL_DB_HOST')
mysql_port = os.getenv('MYSQL_DB_PORT')
mysql_db_name = os.getenv('MYSQL_DB_NAME')
psql_username = os.getenv('DB_USERN')
psql_password = os.getenv('DB_PASS')
psql_host = os.getenv('DB_HOST')
psql_port = os.getenv('DB_PORT')
psql_db_name = os.getenv('DB_NAME')
7 changes: 1 addition & 6 deletions backend/imageCalibrationClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
import time
from imageMaskGeneration import createMask
from imageProcessingClasses import imageProcessing
from imagePredictionClass import MSEStabilization, getPassRef
import pdb
import os
import keyboard
import websocket
from imagePredictionClass import getPassRef
import requests
import pdb

# this function is responsible for creating the pipeline that is connected the machine to the camera
def createPipeline():
Expand Down
4 changes: 0 additions & 4 deletions backend/imagePredictionClass.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

# declare arrays to store the errors for top, left, bottom, right
def getPassRef(error, final):
for i in range(len(error)):
Expand Down
Binary file modified backend/requirements.txt
Binary file not shown.