Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix docker compose #34

Merged
merged 1 commit into from
Dec 4, 2023
Merged
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
27 changes: 16 additions & 11 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
version: "3.11"

services:
mongodb:
image: mongo:latest
container_name: mongo
ports:
- "27017:27017"

frontend:
build: ./web-app # build the Docker image from the Dockerfile in the front-end directory
image: webapp
container_name: webappcontainer
ports:
- 3000:3000 # map port 3000 of host machine to port 3000 of container
- "5000:5000"
depends_on:
- backend
command: python app.py # command to start up the front-end once the container is up and running

mongodb:
image: mongodb/mongodb-community-server:6.0-ubi8
environment:
- MONGO_INITDB_ROOT_USERNAME=user
- MONGO_INITDB_ROOT_PASSWORD=pass
volumes:
- type: bind
source: ./data
target: /data/db

backend:
build: ./machine-learning-client
image: mlclient
container_name: mlcontainer
ports:
- "5001:5001"
depends_on:
- mongodb


19 changes: 9 additions & 10 deletions machine-learning-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
FROM python:3.11

WORKDIR /app

#COPY Pipfile Pipfile.lock ./
WORKDIR /machine-learning-client

#RUN pip install pipenv && pipenv install --deploy --ignore-pipfile
RUN apt-get -y update
COPY requirements.txt ./
# Install ffmpeg for format conversion
RUN apt-get update && apt-get install -y ffmpeg
RUN apt-get -y install libasound-dev
RUN apt-get -y install portaudio19-dev
# Set up microphone access in the Dockerfile
RUN apt-get update && apt-get install -y alsa-utils
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

WORKDIR /usr/src/app
COPY requirements.txt ./
COPY . /machine-learning-client

COPY . .
EXPOSE 5001

RUN pip install -r requirements.txt
ENV NAME World

CMD ["python", "machine_learning_client.py"]
3 changes: 1 addition & 2 deletions machine-learning-client/machine_learning_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

## python3 machine_learning_client.py

client = MongoClient("mongodb://localhost:27017/")
client = MongoClient("mongodb://mongodb:27017/")
db = client["ml_databse"]
collection = db["transcription"]

Expand All @@ -43,7 +43,6 @@ def add_transcription_mongo(transcription, grade_report):

def audio_to_text(audio_file_string):
"""Function for converting audio file to text transcription"""
print("this is not working whhy????")
r = sr.Recognizer()
with sr.AudioFile(audio_file_string) as source:
ad = r.listen(source)
Expand Down
44 changes: 41 additions & 3 deletions machine-learning-client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
pymongo
SpeechRecognition
pyaudio == 0.2.11
-i https://pypi.org/simple
astroid==3.0.1; python_full_version >= '3.8.0'
black==23.11.0; python_version >= '3.8'
blinker==1.7.0; python_version >= '3.8'
certifi==2023.11.17; python_version >= '3.6'
charset-normalizer==3.3.2; python_full_version >= '3.7.0'
click==8.1.7; python_version >= '3.7'
colorama==0.4.6; sys_platform == 'win32'
coverage==7.3.2; python_version >= '3.8'
dill==0.3.7; python_version >= '3.7'
dnspython==2.4.2; python_version >= '3.8' and python_version < '4.0'
flask==3.0.0; python_version >= '3.8'
flask-cors==4.0.0
idna==3.6; python_version >= '3.5'
iniconfig==2.0.0; python_version >= '3.7'
isort==5.12.0; python_full_version >= '3.8.0'
itsdangerous==2.1.2; python_version >= '3.7'
jinja2==3.1.2; python_version >= '3.7'
markupsafe==2.1.3; python_version >= '3.7'
mccabe==0.7.0; python_version >= '3.6'
mypy-extensions==1.0.0; python_version >= '3.5'
packaging==23.2; python_version >= '3.7'
pathspec==0.11.2; python_version >= '3.7'
platformdirs==4.0.0; python_version >= '3.7'
pluggy==1.3.0; python_version >= '3.8'
pyaudio==0.2.14
pydub==0.25.1
pylint==3.0.2; python_full_version >= '3.8.0'
pymongo==4.6.1; python_version >= '3.7'
pytest==7.4.3; python_version >= '3.7'
pytest-cov==4.1.0; python_version >= '3.7'
pytest-flask==1.3.0; python_version >= '3.7'
python-dotenv==1.0.0; python_version >= '3.8'
requests==2.31.0; python_version >= '3.7'
setuptools==69.0.2; python_version >= '3.8'
speechrecognition==3.10.0; python_version >= '3.8'
tomli==2.0.1; python_version >= '3.7'
tomlkit==0.12.3; python_version >= '3.7'
typing-extensions==4.8.0; python_version >= '3.8'
urllib3==2.1.0; python_version >= '3.8'
werkzeug==3.0.1; python_version >= '3.8'
2 changes: 2 additions & 0 deletions mongodb-data/WiredTiger
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WiredTiger
WiredTiger 11.2.0: (November 10, 2022)
1 change: 1 addition & 0 deletions mongodb-data/WiredTiger.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WiredTiger lock file
6 changes: 6 additions & 0 deletions mongodb-data/WiredTiger.turtle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
WiredTiger version string
WiredTiger 11.2.0: (November 10, 2022)
WiredTiger version
major=11,minor=2,patch=0
file:WiredTiger.wt
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=0),value_format=S,verbose=[],version=(major=1,minor=1),write_timestamp_usage=none,checkpoint=(WiredTigerCheckpoint.104=(addr="018081e490eeb18f8181e4cd1e553c8281e4b2460edc808080e3010fc0e23fc0",order=104,time=1701648748,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=23,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=293,run_write_gen=256)),checkpoint_backup_info=,checkpoint_lsn=(19,19968)
Binary file added mongodb-data/WiredTiger.wt
Binary file not shown.
Binary file added mongodb-data/WiredTigerHS.wt
Binary file not shown.
Binary file added mongodb-data/_mdb_catalog.wt
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added mongodb-data/index-1--7574604932032616775.wt
Binary file not shown.
Binary file added mongodb-data/index-1-2954355574068542774.wt
Binary file not shown.
Binary file added mongodb-data/index-3--7574604932032616775.wt
Binary file not shown.
Binary file added mongodb-data/index-5--7574604932032616775.wt
Binary file not shown.
Binary file added mongodb-data/index-6--7574604932032616775.wt
Binary file not shown.
Binary file added mongodb-data/journal/WiredTigerLog.0000000019
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file added mongodb-data/mongod.lock
Empty file.
Binary file added mongodb-data/sizeStorer.wt
Binary file not shown.
Binary file added mongodb-data/storage.bson
Binary file not shown.
18 changes: 12 additions & 6 deletions web-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
FROM python:3.11
WORKDIR /app
ADD . /app

RUN pip install --trusted-host pypi.python.org -r requirements.txt
WORKDIR /web-app

COPY requirements.txt ./

RUN apt-get update && apt-get install -y ffmpeg
RUN apt-get -y install libasound-dev
RUN apt-get -y install portaudio19-dev
RUN pip install --no-cache-dir -r requirements.txt

COPY . /web-app

EXPOSE 5000

EXPOSE 80

# Define an environment variable... this will be available to programs running inside the container
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
4 changes: 2 additions & 2 deletions web-app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
app = Flask("project4")


client = MongoClient("mongodb://localhost:27017/")
client = MongoClient("mongodb://mongodb:27017/")
db = client["ml_databse"]
collection = db["transcription"]

Expand Down Expand Up @@ -51,7 +51,7 @@ def analyze_data():
return jsonify({"status": "error", "message": "No audio file provided"})

audio_file = request.files["audio"]
ml_client_url = "http://127.0.0.1:5001/analyzeAudio"
ml_client_url = "http://backend:5001/analyzeAudio"
# Use the converted audio file
response = requests.post(
ml_client_url, files={"audio": audio_file}, timeout=100
Expand Down
43 changes: 41 additions & 2 deletions web-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
flask
pymongo
-i https://pypi.org/simple
astroid==3.0.1; python_full_version >= '3.8.0'
black==23.11.0; python_version >= '3.8'
blinker==1.7.0; python_version >= '3.8'
certifi==2023.11.17; python_version >= '3.6'
charset-normalizer==3.3.2; python_full_version >= '3.7.0'
click==8.1.7; python_version >= '3.7'
colorama==0.4.6; sys_platform == 'win32'
coverage==7.3.2; python_version >= '3.8'
dill==0.3.7; python_version >= '3.7'
dnspython==2.4.2; python_version >= '3.8' and python_version < '4.0'
flask==3.0.0; python_version >= '3.8'
flask-cors==4.0.0
idna==3.6; python_version >= '3.5'
iniconfig==2.0.0; python_version >= '3.7'
isort==5.12.0; python_full_version >= '3.8.0'
itsdangerous==2.1.2; python_version >= '3.7'
jinja2==3.1.2; python_version >= '3.7'
markupsafe==2.1.3; python_version >= '3.7'
mccabe==0.7.0; python_version >= '3.6'
mypy-extensions==1.0.0; python_version >= '3.5'
packaging==23.2; python_version >= '3.7'
pathspec==0.11.2; python_version >= '3.7'
platformdirs==4.0.0; python_version >= '3.7'
pluggy==1.3.0; python_version >= '3.8'
pyaudio==0.2.14
pydub==0.25.1
pylint==3.0.2; python_full_version >= '3.8.0'
pymongo==4.6.1; python_version >= '3.7'
pytest==7.4.3; python_version >= '3.7'
pytest-cov==4.1.0; python_version >= '3.7'
pytest-flask==1.3.0; python_version >= '3.7'
python-dotenv==1.0.0; python_version >= '3.8'
requests==2.31.0; python_version >= '3.7'
setuptools==69.0.2; python_version >= '3.8'
speechrecognition==3.10.0; python_version >= '3.8'
tomli==2.0.1; python_version >= '3.7'
tomlkit==0.12.3; python_version >= '3.7'
typing-extensions==4.8.0; python_version >= '3.8'
urllib3==2.1.0; python_version >= '3.8'
werkzeug==3.0.1; python_version >= '3.8'
Loading