blob: 1998988793b26177266b83fc02e3268b0b1212da [file] [log] [blame]
Jakub Mand582df92021-02-01 20:48:23 +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 \
Jakub Man67527f82021-02-04 12:36:25 +010011 apache2 apache2-dev libapache2-mod-wsgi-py3
Jakub Mand582df92021-02-01 20:48:23 +010012
13RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - && apt-get install -y nodejs
14
15# Install libssh from source (Version from apt is incompatible with libnetconf2)
16RUN git clone -b v0-7 http://git.libssh.org/projects/libssh.git ; cd libssh; mkdir build; cd build ;\
Jakub Man67527f82021-02-04 12:36:25 +010017 cmake ..; make; make install ; cd /
Jakub Mand582df92021-02-01 20:48:23 +010018
19# Install libyang
20RUN git clone -b devel https://github.com/CESNET/libyang.git && cd libyang; \
21 mkdir build; cd build && \
Jakub Man67527f82021-02-04 12:36:25 +010022 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_JAVA_BINDINGS=OFF .. && make && make install && cd ../.. && ldconfig ; cd /
Jakub Mand582df92021-02-01 20:48:23 +010023
24# Install libnetconf2
Jakub Man67527f82021-02-04 12:36:25 +010025RUN git clone -b devel https://github.com/CESNET/libnetconf2.git && cd libnetconf2 && \
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
Jakub Mand582df92021-02-01 20:48:23 +010030
31# Install sysrepo
32RUN git clone -b devel https://github.com/sysrepo/sysrepo.git ; \
33 cd sysrepo; mkdir build; cd build; \
34 cmake -DGEN_LANGUAGE_BINDINGS=OFF .. && make && make install; \
35 cd ../.. ; \
Jakub Man67527f82021-02-04 12:36:25 +010036 ldconfig ; cd /
Jakub Mand582df92021-02-01 20:48:23 +010037
38# Install netopeer
39RUN git clone -b devel https://github.com/CESNET/Netopeer2.git ;\
40 cd Netopeer2; mkdir build; cd build ;\
Jakub Man67527f82021-02-04 12:36:25 +010041 cmake .. && make && make install ; cd /
Jakub Mand582df92021-02-01 20:48:23 +010042
43# Prepare GUI
Jakub Man67527f82021-02-04 12:36:25 +010044RUN 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
Jakub Mand582df92021-02-01 20:48:23 +010048RUN cd /liberouter-gui && python3 bootstrap.py && \
49 pip3 install -r backend/requirements.txt && \
Jakub Man67527f82021-02-04 12:36:25 +010050 cd frontend && npm install -g npm@7.5.2 && \
51 npm i -g @angular/cli && npm install --legacy-peer-deps
Jakub Mand582df92021-02-01 20:48:23 +010052
Jakub Man12e5fc82021-02-04 15:57:36 +010053# 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
Jakub Mand582df92021-02-01 20:48:23 +010059# Build GUI
60RUN mkdir /etc/httpd ; mkdir /etc/httpd/conf.modules.d
61RUN pip3 install mod_wsgi
62RUN mod_wsgi-express module-config >/etc/httpd/conf.modules.d/00-wsgi.conf
Jakub Man67527f82021-02-04 12:36:25 +010063RUN pip3 uninstall mod_wsgi -y
64RUN cd /liberouter-gui/modules/netopeer2gui/frontend && npm i && npm run build:tools && cd
Jakub Mand582df92021-02-01 20:48:23 +010065RUN cd /liberouter-gui/frontend && npm run build && cp -R dist/* /var/www/html
Jakub Mand582df92021-02-01 20:48:23 +010066
Jakub Man67527f82021-02-04 12:36:25 +010067# Setup apache server
68RUN mkdir -p /var/www/liberouter-gui && cp -r /liberouter-gui/backend /var/www/liberouter-gui
Jakub Man12e5fc82021-02-04 15:57:36 +010069RUN rm /var/www/liberouter-gui/backend/liberouterapi/modules/netconf && cp -r /liberouter-gui/modules/netopeer2gui/backend/. /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui
Jakub Man67527f82021-02-04 12:36:25 +010070RUN cp /liberouter-gui/modules/netopeer2gui/docker/wsgi.py /var/www/liberouter-gui/backend/wsgi.py
71COPY liberouter.conf /etc/apache2/sites-available
72RUN a2ensite liberouter && a2dissite 000-default
Jakub Man12e5fc82021-02-04 15:57:36 +010073RUN a2enmod rewrite
Jakub Man67527f82021-02-04 12:36:25 +010074COPY config.ini /var/www/liberouter-gui/backend/config.ini
Jakub Man12e5fc82021-02-04 15:57:36 +010075COPY .htaccess /var/www/html/.htaccess
Jakub Man67527f82021-02-04 12:36:25 +010076RUN chown -R www-data:www-data /var/www/liberouter-gui
Jakub Man12e5fc82021-02-04 15:57:36 +010077RUN chown -R www-data:www-data /liberouter-gui/modules/netopeer2gui/backend
78# App needs to write configuration files
79RUN chmod -R +w /var/www/liberouter-gui
80
81# Change root password for netconf connection
82# DO NOT USE IN PRODUCTION ENVIRONMENT!
83RUN echo 'root:docker' | chpasswd
Jakub Mand582df92021-02-01 20:48:23 +010084
Jakub Man67527f82021-02-04 12:36:25 +010085# Expose HTTP
86EXPOSE 80/tcp
Jakub Man12e5fc82021-02-04 15:57:36 +010087EXPOSE 830
Jakub Man67527f82021-02-04 12:36:25 +010088
89
90COPY services.sh /root
91CMD ["/bin/bash", "/root/services.sh"]