Reputation: 1425
I created a simple Flask web app with CRUD operations and deployed in beanstalk with the below requirements.txt file
Flask==1.1.1
Flask-MySQLdb==0.2.0
Jinja2==2.11.1
mysql==0.0.2
mysqlclient==1.4.6
SQLAlchemy==1.3.15
Werkzeug==1.0.0
Flask-Cors==3.0.8
Flask-Mail==0.9.1
Flask-SocketIO==4.3.0
It worked fine, and then I wrote a below function
import tensorflow as tf
import keras
from keras.models import load_model
import cv2
import os
def face_shape_model():
classifier = load_model('face_shape_recog_model.h5')
image = cv2.imread('')
res = str(classifier.predict_classes(image, 1, verbose=0)[0])
return {"prediction": res}
with including below packages in to requirments.txt file
keras==2.3.1
tensorflow==1.14.0
opencv-python==4.2.0.32
whole flask application working fine in my local environment so I zipped and deploy into AWS elasticbeanstalk after deployment it logged below error
Unsuccessful command execution on instance id(s) 'i-0a2a8a4c5b3e56b81'. Aborting the operation.
Your requirements.txt is invalid. Snapshot your logs for details.
as mentioned above I checked my log and it shows below error
distutils.errors.CompileError: command 'gcc' failed with exit status 1
so I searched about the above error find below solution according to that and I created yml file and added it into .ebextension file as below
packages:
yum:
gcc-c++: []
but I still get the same error. how can I solve this or is there any wrong steps above
Thank you.
Upvotes: 1
Views: 800
Reputation: 1425
Finally solved with docker container, I created docker environment In AWS ElasticBeanstalk and deployed it, and now it works fine, below shows my config file and Dockerfile
Dockerfile
FROM python:3.6.8
RUN mkdir -p /usr/src/flask_app/
COPY src/requirements.txt /usr/src/flask_app/
WORKDIR /usr/src/flask_app/
RUN pip install -r requirements.txt
COPY . /usr/src/flask_app
ENTRYPOINT ["python", "src/app.py"]
EXPOSE 5000
Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"Ports": [
{
"ContainerPort": "5000",
"HostPort": "80"
}
]
}
Upvotes: 2