blob: 5d35e19437bff73d60bf18c3c2f4443cc23d88f7 [file] [log] [blame]
Jakub Mand521d6b2021-02-09 22:07:27 +01001FROM ubuntu:18.04
2
3# Install required binaries
4RUN apt-get upgrade && apt-get update -y && apt-get install -y \
5 mongodb python3 python3-dev python3-pip \
6 pkg-config \
7 git cmake clang curl \
8 libpcre3-dev swig \
9 zlib1g-dev libgcrypt-dev libssl-dev \
10 libprotobuf-c-dev protobuf-c-compiler libavl-dev libev-dev \
11 libffi-dev python3-setuptools nginx
12
Jakub Man51f072c2021-07-08 15:48:57 +020013RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
Jakub Mand521d6b2021-02-09 22:07:27 +010014
15# Install libssh from source (Version from apt is incompatible with libnetconf2)
16RUN git clone -b stable-0.8 http://git.libssh.org/projects/libssh.git ; cd libssh; mkdir build; cd build ;\
17 cmake ..; make; make install ; cd /
18
19# Install libyang
Jakub Man51f072c2021-07-08 15:48:57 +020020RUN git clone -b libyang1 https://github.com/CESNET/libyang.git && cd libyang; \
Jakub Mand521d6b2021-02-09 22:07:27 +010021 mkdir build; cd build && \
22 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_JAVA_BINDINGS=OFF .. && make && make install && cd ../.. && ldconfig ; cd /
23
24# Install libnetconf2
Jakub Man51f072c2021-07-08 15:48:57 +020025RUN git clone -b libyang1 https://github.com/CESNET/libnetconf2.git && cd libnetconf2 && \
Jakub Mand521d6b2021-02-09 22:07:27 +010026 mkdir build && cd build && \
27 cmake -DENABLE_PYTHON=ON .. && make && make install && cd ../.. && ldconfig && \
28 python3 /libnetconf2/build/python/setup.py install && cd /
29# Manually running setup.py is a temporary workaround because of a bug in libnetconf2
30
31# Install sysrepo
Jakub Man51f072c2021-07-08 15:48:57 +020032RUN git clone -b libyang1 https://github.com/sysrepo/sysrepo.git ; \
Jakub Mand521d6b2021-02-09 22:07:27 +010033 cd sysrepo; mkdir build; cd build; \
34 cmake -DGEN_LANGUAGE_BINDINGS=OFF .. && make && make install; \
35 cd ../.. ; \
36 ldconfig ; cd /
37
38# Install netopeer
39RUN git clone -b devel https://github.com/CESNET/Netopeer2.git ;\
40 cd Netopeer2; mkdir build; cd build ;\
41 cmake .. && make && make install ; cd /
42
43# Prepare GUI
44RUN git clone https://github.com/CESNET/liberouter-gui
45RUN cd /liberouter-gui/modules && git clone -b v2 https://github.com/CESNET/netopeer2gui
46# && rm -rf /liberouter-gui/modules/example
47RUN cp /liberouter-gui/modules/netopeer2gui/app.config.json /liberouter-gui/modules/app.config.json && rm /liberouter-gui/modules/netopeer2gui/app.config.json
48RUN cd /liberouter-gui && python3 bootstrap.py && \
49 pip3 install -r backend/requirements.txt && \
50 cd frontend && npm install -g npm@7.5.2 && \
51 npm i -g @angular/cli && npm install --legacy-peer-deps
52
53# Temporary workaround until import is fixed for tools
54RUN rm /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss && \
55 cp /liberouter-gui/frontend/src/styles/_colors.scss /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss
56RUN echo "\$colorSuccess: #44bd32;" >> /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss && \
57 echo "\$colorError: #ee1d23;" >> /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss
58
59# Build GUI
60RUN cd /liberouter-gui/modules/netopeer2gui/frontend && npm i && npm run build:tools && cd
61RUN cd /liberouter-gui/frontend && npm run build && cp -R dist/* /var/www/html
62
63# Setup ngix server with uwsgi
64RUN mkdir -p /var/www/liberouter-gui && cp -r /liberouter-gui/backend /var/www/liberouter-gui
65RUN rm /var/www/liberouter-gui/backend/liberouterapi/modules/netconf && cp -r /liberouter-gui/modules/netopeer2gui/backend/. /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui
66RUN cp /liberouter-gui/modules/netopeer2gui/docker/wsgi.py /var/www/liberouter-gui/backend/wsgi.py
67RUN pip3 install wheel && pip3 install uwsgi; mkdir /uwsgi; chown -R www-data:www-data /uwsgi
68
69COPY localhost /etc/nginx/sites-available/
70RUN ln /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled
71
72COPY config.ini /var/www/liberouter-gui/backend/config.ini
73COPY .htaccess /var/www/html/.htaccess
74RUN chown -R www-data:www-data /var/www/liberouter-gui
75RUN chown -R www-data:www-data /liberouter-gui/modules/netopeer2gui/backend
76# App needs to write configuration files
77RUN chmod -R +w /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui/ ; mkdir -p /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui/userfiles
78RUN rm /etc/nginx/sites-enabled/default
79RUN pip3 install Flask-SocketIO==4.3.2
80
81# Change root password for netconf connection
82# DO NOT USE IN PRODUCTION ENVIRONMENT!
83RUN echo 'root:docker' | chpasswd
84
85# Expose HTTP
86EXPOSE 80/tcp
87EXPOSE 5555/tcp
88# EXPOSE 830
89
90COPY services.sh /root
91CMD ["/bin/bash", "/root/services.sh"]