diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..9748846 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,115 @@ +FROM ubuntu:14.04 +MAINTAINER Jonathan Brilhante +#USER root + +#Dependencies installation - RabbitMQ / Graylog / Nodejs / Redis / MongoDB / FFmpeg + +#Packages updates +RUN apt-get -y update +RUN apt-get -y upgrade +RUN apt-get -y update + +#Install necessary packages +RUN apt-get install -y build-essential libssl-dev sudo curl wget + +#RUN apt-get install default-jdk -y +#RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - + +#Install Nodejs +RUN curl -sL https://deb.nodesource.com/setup | sudo bash - +RUN apt-get install -y nodejs + +#Install python packages +RUN apt-get install -y python-setuptools +RUN easy_install pip + +#RUN npm install -g express-generator +#RUN cd $(npm root -g)/npm && npm install fs-extra && sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs.move/ ./lib/utils/rename.js + +#Install RabbitMQ +RUN echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list +RUN wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add - +RUN apt-get -y update +RUN apt-get install -y rabbitmq-server + +#Install python and python lib for RabbitMQ +RUN apt-get install -y python +RUN pip install pika + +#Install Graylog +RUN pip install graypy +RUN pip install graypy[amqp] + +#Enable RabbitMQ plugins +RUN rabbitmq-plugins enable rabbitmq_management + +#Install aditional packages +RUN apt-get install -y pkg-config libfreetype6-dev libpng-dev xvfb +RUN apt-get install -y python-yaml libgomp1 python-numpy python-pyfits python-matplotlib idle +RUN pip install nltk==3.0.5 nltk_tgrep --upgrade +RUN pip install pysrt pyvirtualdisplay +RUN apt-get install -y software-properties-common + +#Install FFmpeg +RUN add-apt-repository ppa:mc3man/trusty-media +RUN apt-get -y update +RUN apt-get install -y ffmpeg gstreamer0.10-ffmpeg + +#Install Redis +RUN apt-get install -y redis-server +RUN service redis-server restart + +#Install MongoDB +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 +RUN echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list +RUN apt-get -y update && apt-get install -y mongodb-org +RUN mkdir -p /data/db + +WORKDIR / +RUN mkdir /storage/ + +#Copy workers to container +WORKDIR /root/ +COPY ./core/extractor.py /root/extractor.py +COPY ./core/mixer.py /root/mixer.py +COPY ./core/renderer.py /root/renderer.py +COPY ./core/translator.py /root/translator.py +COPY ./core/PikaManager.py /root/PikaManager.py +COPY ./core/processManager.py /root/processManager.py +COPY ./unityVideo/ /root/unityVideo/ +COPY ./vlibras-translate/ /root/vlibras-translate/ +COPY ./vlibras-libs/ /root/vlibras-libs/ +COPY ./vlibras-api/ /root/vlibras-api/ + +#Workers environment variables +ENV VLIBRAS_VIDEO_CREATOR="/root/unityVideo/videoCreator.x86_64" +ENV VLIBRAS_VIDEO_LIBRAS="/root/storage/libras" +ENV VLIBRAS_VIDEO_MIXED="/root/storage/videos" + +#Translator environment variables +ENV HUNPOS_TAGGER="/root/vlibras-libs/aelius/bin/hunpos-tag" +ENV AELIUS_DATA="/root/vlibras-libs/aelius/aelius_data" +ENV TRANSLATE_DATA="/root/vlibras-translate/data" +ENV NLTK_DATA="/root/vlibras-libs/aelius/nltk_data" +ENV PYTHONPATH=":/root/vlibras-libs/aelius:/root/vlibras-translate/src:/root/vlibras-libs/aelius:/root/vlibras-translate/src" + +#ENV NODE_PATH=/root/vlibras-api/node_modules/;%NODE_PATH% + +#Portas de comunicacao do container +EXPOSE 27017 +EXPOSE 5672 +EXPOSE 80:80 +#EXPOSE 15672 +WORKDIR /root/vlibras-api/ +VOLUME ["/root/volume/", "/storage/"] +RUN npm cache clean +RUN rm -rf node_modules +RUN npm i +COPY ./vlibras-api/node_modules/amqplib/ /root/vlibras-api/node_modules/amqplib/ +RUN npm --version +RUN node --version + +RUN /usr/bin/mongod & + +#Comando de entrada quando inicializado +ENTRYPOINT (/usr/bin/mongod & redis-server & rabbitmq-server start & sleep 3m) ; (node server.js & sleep 10) ; python /root/extractor.py & python /root/translator.py & python /root/renderer.py & python /root/mixer.py diff --git a/core/mixer.py b/core/mixer.py index f7d2afc..361271a 100755 --- a/core/mixer.py +++ b/core/mixer.py @@ -81,7 +81,7 @@ def main_video_height(main_video): video_height = json.loads(ffprobe.communicate()[0]) # Returns the height obtained return video_height['streams'][0]['height'] - except OSError as ex: + except: logger.error("Error when extracting resolution, default will be used") return None diff --git a/core/renderer.py b/core/renderer.py index ce2de38..df16bc7 100755 --- a/core/renderer.py +++ b/core/renderer.py @@ -15,6 +15,9 @@ from pyvirtualdisplay import Display from thread import start_new_thread from time import sleep +#Temporary +from shutil import rmtree + # Logging configuration. logger = logging.getLogger('renderer') logger.setLevel(logging.DEBUG) @@ -41,6 +44,9 @@ TCP_PORT = 5555 PATH_LIBRAS = os.getenv("VLIBRAS_VIDEO_LIBRAS") VIDEO_CREATOR = os.getenv("VLIBRAS_VIDEO_CREATOR") +#Temporary +PATH_SCREENS = "/storage/frames/" + # Status of renderer to process new requests. Answer one request at a time. worker_available = True # Identification to indicate the request being processed. @@ -201,11 +207,13 @@ def run(ch, method, properties, body): logger.info("Preparing to generate the video") start_new_thread(send_to_video_creator, (correlation_id,)) start_video_creator(correlation_id) + #Temporary + clean(correlation_id) # Add path of libras video on body. body["libras-video"] = os.path.join(PATH_LIBRAS, correlation_id + ".mp4") worker_available = True correlation_id = None - logger.info("Sending libras video to the translations queue") + logger.info("Sending libras video to the libras queue") manager.send_to_queue("libras", body, properties) print ("OK") else: @@ -216,6 +224,12 @@ def run(ch, method, properties, body): else: ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True) +#Temporary +def clean(id): + logger.info("Cleaning screens files") + path = os.path.join(PATH_SCREENS, id) + rmtree(path, ignore_errors=True) + def keep_alive(conn_send, conn_receive): """ Keep the connection alive. -- libgit2 0.21.2