Jakub Man | d521d6b | 2021-02-09 22:07:27 +0100 | [diff] [blame] | 1 | FROM ubuntu:18.04 |
| 2 | |
| 3 | # Install required binaries |
| 4 | RUN 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 Man | 51f072c | 2021-07-08 15:48:57 +0200 | [diff] [blame] | 13 | RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs |
Jakub Man | d521d6b | 2021-02-09 22:07:27 +0100 | [diff] [blame] | 14 | |
| 15 | # Install libssh from source (Version from apt is incompatible with libnetconf2) |
| 16 | RUN 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 Man | 51f072c | 2021-07-08 15:48:57 +0200 | [diff] [blame] | 20 | RUN git clone -b libyang1 https://github.com/CESNET/libyang.git && cd libyang; \ |
Jakub Man | d521d6b | 2021-02-09 22:07:27 +0100 | [diff] [blame] | 21 | 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 Man | 51f072c | 2021-07-08 15:48:57 +0200 | [diff] [blame] | 25 | RUN git clone -b libyang1 https://github.com/CESNET/libnetconf2.git && cd libnetconf2 && \ |
Jakub Man | d521d6b | 2021-02-09 22:07:27 +0100 | [diff] [blame] | 26 | 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 Man | 51f072c | 2021-07-08 15:48:57 +0200 | [diff] [blame] | 32 | RUN git clone -b libyang1 https://github.com/sysrepo/sysrepo.git ; \ |
Jakub Man | d521d6b | 2021-02-09 22:07:27 +0100 | [diff] [blame] | 33 | cd sysrepo; mkdir build; cd build; \ |
| 34 | cmake -DGEN_LANGUAGE_BINDINGS=OFF .. && make && make install; \ |
| 35 | cd ../.. ; \ |
| 36 | ldconfig ; cd / |
| 37 | |
| 38 | # Install netopeer |
| 39 | RUN 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 |
| 44 | RUN git clone https://github.com/CESNET/liberouter-gui |
| 45 | RUN cd /liberouter-gui/modules && git clone -b v2 https://github.com/CESNET/netopeer2gui |
| 46 | # && rm -rf /liberouter-gui/modules/example |
| 47 | RUN cp /liberouter-gui/modules/netopeer2gui/app.config.json /liberouter-gui/modules/app.config.json && rm /liberouter-gui/modules/netopeer2gui/app.config.json |
| 48 | RUN 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 |
| 54 | RUN 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 |
| 56 | RUN 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 |
| 60 | RUN cd /liberouter-gui/modules/netopeer2gui/frontend && npm i && npm run build:tools && cd |
| 61 | RUN cd /liberouter-gui/frontend && npm run build && cp -R dist/* /var/www/html |
| 62 | |
| 63 | # Setup ngix server with uwsgi |
| 64 | RUN mkdir -p /var/www/liberouter-gui && cp -r /liberouter-gui/backend /var/www/liberouter-gui |
| 65 | RUN rm /var/www/liberouter-gui/backend/liberouterapi/modules/netconf && cp -r /liberouter-gui/modules/netopeer2gui/backend/. /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui |
| 66 | RUN cp /liberouter-gui/modules/netopeer2gui/docker/wsgi.py /var/www/liberouter-gui/backend/wsgi.py |
| 67 | RUN pip3 install wheel && pip3 install uwsgi; mkdir /uwsgi; chown -R www-data:www-data /uwsgi |
| 68 | |
| 69 | COPY localhost /etc/nginx/sites-available/ |
| 70 | RUN ln /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled |
| 71 | |
| 72 | COPY config.ini /var/www/liberouter-gui/backend/config.ini |
| 73 | COPY .htaccess /var/www/html/.htaccess |
| 74 | RUN chown -R www-data:www-data /var/www/liberouter-gui |
| 75 | RUN chown -R www-data:www-data /liberouter-gui/modules/netopeer2gui/backend |
| 76 | # App needs to write configuration files |
| 77 | RUN chmod -R +w /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui/ ; mkdir -p /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui/userfiles |
| 78 | RUN rm /etc/nginx/sites-enabled/default |
| 79 | RUN pip3 install Flask-SocketIO==4.3.2 |
| 80 | |
| 81 | # Change root password for netconf connection |
| 82 | # DO NOT USE IN PRODUCTION ENVIRONMENT! |
| 83 | RUN echo 'root:docker' | chpasswd |
| 84 | |
| 85 | # Expose HTTP |
| 86 | EXPOSE 80/tcp |
| 87 | EXPOSE 5555/tcp |
| 88 | # EXPOSE 830 |
| 89 | |
| 90 | COPY services.sh /root |
| 91 | CMD ["/bin/bash", "/root/services.sh"] |