Commit d7419300a06eecfae6fa6fe251a69e509cb0b22d
1 parent
a047b83b
Exists in
release
Add Dockerfile
Showing
3 changed files
with
131 additions
and
2 deletions
Show diff stats
... | ... | @@ -0,0 +1,115 @@ |
1 | +FROM ubuntu:14.04 | |
2 | +MAINTAINER Jonathan Brilhante | |
3 | +#USER root | |
4 | + | |
5 | +#Dependencies installation - RabbitMQ / Graylog / Nodejs / Redis / MongoDB / FFmpeg | |
6 | + | |
7 | +#Packages updates | |
8 | +RUN apt-get -y update | |
9 | +RUN apt-get -y upgrade | |
10 | +RUN apt-get -y update | |
11 | + | |
12 | +#Install necessary packages | |
13 | +RUN apt-get install -y build-essential libssl-dev sudo curl wget | |
14 | + | |
15 | +#RUN apt-get install default-jdk -y | |
16 | +#RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - | |
17 | + | |
18 | +#Install Nodejs | |
19 | +RUN curl -sL https://deb.nodesource.com/setup | sudo bash - | |
20 | +RUN apt-get install -y nodejs | |
21 | + | |
22 | +#Install python packages | |
23 | +RUN apt-get install -y python-setuptools | |
24 | +RUN easy_install pip | |
25 | + | |
26 | +#RUN npm install -g express-generator | |
27 | +#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 | |
28 | + | |
29 | +#Install RabbitMQ | |
30 | +RUN echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list | |
31 | +RUN wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add - | |
32 | +RUN apt-get -y update | |
33 | +RUN apt-get install -y rabbitmq-server | |
34 | + | |
35 | +#Install python and python lib for RabbitMQ | |
36 | +RUN apt-get install -y python | |
37 | +RUN pip install pika | |
38 | + | |
39 | +#Install Graylog | |
40 | +RUN pip install graypy | |
41 | +RUN pip install graypy[amqp] | |
42 | + | |
43 | +#Enable RabbitMQ plugins | |
44 | +RUN rabbitmq-plugins enable rabbitmq_management | |
45 | + | |
46 | +#Install aditional packages | |
47 | +RUN apt-get install -y pkg-config libfreetype6-dev libpng-dev xvfb | |
48 | +RUN apt-get install -y python-yaml libgomp1 python-numpy python-pyfits python-matplotlib idle | |
49 | +RUN pip install nltk==3.0.5 nltk_tgrep --upgrade | |
50 | +RUN pip install pysrt pyvirtualdisplay | |
51 | +RUN apt-get install -y software-properties-common | |
52 | + | |
53 | +#Install FFmpeg | |
54 | +RUN add-apt-repository ppa:mc3man/trusty-media | |
55 | +RUN apt-get -y update | |
56 | +RUN apt-get install -y ffmpeg gstreamer0.10-ffmpeg | |
57 | + | |
58 | +#Install Redis | |
59 | +RUN apt-get install -y redis-server | |
60 | +RUN service redis-server restart | |
61 | + | |
62 | +#Install MongoDB | |
63 | +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | |
64 | +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 | |
65 | +RUN apt-get -y update && apt-get install -y mongodb-org | |
66 | +RUN mkdir -p /data/db | |
67 | + | |
68 | +WORKDIR / | |
69 | +RUN mkdir /storage/ | |
70 | + | |
71 | +#Copy workers to container | |
72 | +WORKDIR /root/ | |
73 | +COPY ./core/extractor.py /root/extractor.py | |
74 | +COPY ./core/mixer.py /root/mixer.py | |
75 | +COPY ./core/renderer.py /root/renderer.py | |
76 | +COPY ./core/translator.py /root/translator.py | |
77 | +COPY ./core/PikaManager.py /root/PikaManager.py | |
78 | +COPY ./core/processManager.py /root/processManager.py | |
79 | +COPY ./unityVideo/ /root/unityVideo/ | |
80 | +COPY ./vlibras-translate/ /root/vlibras-translate/ | |
81 | +COPY ./vlibras-libs/ /root/vlibras-libs/ | |
82 | +COPY ./vlibras-api/ /root/vlibras-api/ | |
83 | + | |
84 | +#Workers environment variables | |
85 | +ENV VLIBRAS_VIDEO_CREATOR="/root/unityVideo/videoCreator.x86_64" | |
86 | +ENV VLIBRAS_VIDEO_LIBRAS="/root/storage/libras" | |
87 | +ENV VLIBRAS_VIDEO_MIXED="/root/storage/videos" | |
88 | + | |
89 | +#Translator environment variables | |
90 | +ENV HUNPOS_TAGGER="/root/vlibras-libs/aelius/bin/hunpos-tag" | |
91 | +ENV AELIUS_DATA="/root/vlibras-libs/aelius/aelius_data" | |
92 | +ENV TRANSLATE_DATA="/root/vlibras-translate/data" | |
93 | +ENV NLTK_DATA="/root/vlibras-libs/aelius/nltk_data" | |
94 | +ENV PYTHONPATH=":/root/vlibras-libs/aelius:/root/vlibras-translate/src:/root/vlibras-libs/aelius:/root/vlibras-translate/src" | |
95 | + | |
96 | +#ENV NODE_PATH=/root/vlibras-api/node_modules/;%NODE_PATH% | |
97 | + | |
98 | +#Portas de comunicacao do container | |
99 | +EXPOSE 27017 | |
100 | +EXPOSE 5672 | |
101 | +EXPOSE 80:80 | |
102 | +#EXPOSE 15672 | |
103 | +WORKDIR /root/vlibras-api/ | |
104 | +VOLUME ["/root/volume/", "/storage/"] | |
105 | +RUN npm cache clean | |
106 | +RUN rm -rf node_modules | |
107 | +RUN npm i | |
108 | +COPY ./vlibras-api/node_modules/amqplib/ /root/vlibras-api/node_modules/amqplib/ | |
109 | +RUN npm --version | |
110 | +RUN node --version | |
111 | + | |
112 | +RUN /usr/bin/mongod & | |
113 | + | |
114 | +#Comando de entrada quando inicializado | |
115 | +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 | ... | ... |
core/mixer.py
... | ... | @@ -81,7 +81,7 @@ def main_video_height(main_video): |
81 | 81 | video_height = json.loads(ffprobe.communicate()[0]) |
82 | 82 | # Returns the height obtained |
83 | 83 | return video_height['streams'][0]['height'] |
84 | - except OSError as ex: | |
84 | + except: | |
85 | 85 | logger.error("Error when extracting resolution, default will be used") |
86 | 86 | return None |
87 | 87 | ... | ... |
core/renderer.py
... | ... | @@ -15,6 +15,9 @@ from pyvirtualdisplay import Display |
15 | 15 | from thread import start_new_thread |
16 | 16 | from time import sleep |
17 | 17 | |
18 | +#Temporary | |
19 | +from shutil import rmtree | |
20 | + | |
18 | 21 | # Logging configuration. |
19 | 22 | logger = logging.getLogger('renderer') |
20 | 23 | logger.setLevel(logging.DEBUG) |
... | ... | @@ -41,6 +44,9 @@ TCP_PORT = 5555 |
41 | 44 | PATH_LIBRAS = os.getenv("VLIBRAS_VIDEO_LIBRAS") |
42 | 45 | VIDEO_CREATOR = os.getenv("VLIBRAS_VIDEO_CREATOR") |
43 | 46 | |
47 | +#Temporary | |
48 | +PATH_SCREENS = "/storage/frames/" | |
49 | + | |
44 | 50 | # Status of renderer to process new requests. Answer one request at a time. |
45 | 51 | worker_available = True |
46 | 52 | # Identification to indicate the request being processed. |
... | ... | @@ -201,11 +207,13 @@ def run(ch, method, properties, body): |
201 | 207 | logger.info("Preparing to generate the video") |
202 | 208 | start_new_thread(send_to_video_creator, (correlation_id,)) |
203 | 209 | start_video_creator(correlation_id) |
210 | + #Temporary | |
211 | + clean(correlation_id) | |
204 | 212 | # Add path of libras video on body. |
205 | 213 | body["libras-video"] = os.path.join(PATH_LIBRAS, correlation_id + ".mp4") |
206 | 214 | worker_available = True |
207 | 215 | correlation_id = None |
208 | - logger.info("Sending libras video to the translations queue") | |
216 | + logger.info("Sending libras video to the libras queue") | |
209 | 217 | manager.send_to_queue("libras", body, properties) |
210 | 218 | print ("OK") |
211 | 219 | else: |
... | ... | @@ -216,6 +224,12 @@ def run(ch, method, properties, body): |
216 | 224 | else: |
217 | 225 | ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True) |
218 | 226 | |
227 | +#Temporary | |
228 | +def clean(id): | |
229 | + logger.info("Cleaning screens files") | |
230 | + path = os.path.join(PATH_SCREENS, id) | |
231 | + rmtree(path, ignore_errors=True) | |
232 | + | |
219 | 233 | def keep_alive(conn_send, conn_receive): |
220 | 234 | """ |
221 | 235 | Keep the connection alive. | ... | ... |