Eric Tang | 58b773d | 2019-02-22 14:03:36 +0800 | [diff] [blame] | 1 | FROM ubuntu:18.04 |
| 2 | LABEL maintainer="Eric Tang <qcorba at gmail.com>" |
| 3 | |
| 4 | ARG ATOMIX_VERSION |
pierventre | b59c51d | 2021-05-06 09:27:00 +0200 | [diff] [blame] | 5 | ENV ENV_ATOMIX_VERSION=${ATOMIX_VERSION:-3.1.12} |
Eric Tang | 58b773d | 2019-02-22 14:03:36 +0800 | [diff] [blame] | 6 | |
pierventre | b59c51d | 2021-05-06 09:27:00 +0200 | [diff] [blame] | 7 | RUN apt-get update |
Eric Tang | 58b773d | 2019-02-22 14:03:36 +0800 | [diff] [blame] | 8 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \ |
| 9 | --no-install-recommends \ |
| 10 | openjdk-11-jre \ |
| 11 | python-setuptools \ |
| 12 | python-pip \ |
| 13 | openssh-server \ |
| 14 | supervisor \ |
| 15 | vim-tiny \ |
| 16 | net-tools \ |
| 17 | iputils-ping \ |
| 18 | curl \ |
| 19 | sudo |
| 20 | |
| 21 | RUN set -eux; \ |
| 22 | groupadd -r sdn; \ |
| 23 | useradd -m -r -s /bin/bash -g sdn sdn; \ |
| 24 | echo sdn:sdn | chpasswd; \ |
| 25 | echo 'sdn ALL=(ALL:ALL) NOPASSWD:ALL' > /etc/sudoers.d/sdn |
| 26 | |
| 27 | USER sdn |
| 28 | RUN mkdir /home/sdn/.ssh |
| 29 | RUN ssh-keygen -t rsa -N "" -f /home/sdn/.ssh/id_rsa |
| 30 | |
| 31 | USER root |
| 32 | COPY --chown=sdn:sdn id_rsa.pub /home/sdn/.ssh/authorized_keys |
| 33 | RUN chmod 600 /home/sdn/.ssh/authorized_keys |
| 34 | |
| 35 | # Configure supervisor |
| 36 | RUN set -eux; \ |
| 37 | mv /etc/supervisor/supervisord.conf /etc/supervisor/supervisord-orig.conf; \ |
| 38 | mkdir -p /var/log/supervisor; \ |
| 39 | mkdir -p /var/run/sshd; \ |
| 40 | chmod 700 /var/run/sshd |
| 41 | COPY supervisord.conf /etc/supervisor/ |
| 42 | COPY supervisord-sshd.conf /etc/supervisor/conf.d/sshd.conf |
| 43 | COPY supervisord-onos.conf /etc/supervisor/conf.d/onos.conf |
| 44 | COPY supervisord-atomix.conf /etc/supervisor/conf.d/atomix.conf |
| 45 | |
| 46 | # Install ONOS |
| 47 | COPY onos.tar.gz /tmp/ |
| 48 | RUN set -eux; \ |
| 49 | mkdir /opt/onos; \ |
| 50 | tar zxmf /tmp/onos.tar.gz -C /opt/onos --strip-components=1; \ |
| 51 | ln -s /opt/onos/apache-karaf-* /opt/onos/karaf; \ |
| 52 | ln -s /opt/onos/karaf/data/log /opt/onos/log; \ |
| 53 | mkdir /opt/onos/var; \ |
| 54 | mkdir /opt/onos/config; \ |
| 55 | # Install the configuration file(s) |
| 56 | #cp /opt/onos/init/onos.conf /etc/init/onos.conf; \ |
| 57 | cp /opt/onos/init/onos.initd /etc/init.d/onos; \ |
| 58 | cp /opt/onos/init/onos.service /etc/systemd/system/onos.service; \ |
| 59 | # Set up options for debugging |
| 60 | echo 'export ONOS_OPTS=debug' > /opt/onos/options; \ |
| 61 | # Set up correct user to run onos-service |
| 62 | echo 'export ONOS_USER=sdn' >> /opt/onos/options; \ |
| 63 | # Configure ONOS to log to stdout |
| 64 | sed -ibak '/log4j.rootLogger=/s/$/, stdout/' $(ls -d /opt/onos/apache-karaf-*)/etc/org.ops4j.pax.logging.cfg; \ |
| 65 | chown -R sdn:sdn /opt/onos |
| 66 | |
| 67 | # Install Atomix |
| 68 | RUN set -eux; \ |
pierventre | b59c51d | 2021-05-06 09:27:00 +0200 | [diff] [blame] | 69 | # curl -o /tmp/atomix.tar.gz -XGET https://oss.sonatype.org/content/repositories/releases/io/atomix/atomix-dist/3.1.12/atomix-dist-3.1.12.tar.gz; \ |
Eric Tang | 58b773d | 2019-02-22 14:03:36 +0800 | [diff] [blame] | 70 | curl -o /tmp/atomix.tar.gz https://repo1.maven.org/maven2/io/atomix/atomix-dist/$ENV_ATOMIX_VERSION/atomix-dist-$ENV_ATOMIX_VERSION.tar.gz; \ |
| 71 | mkdir /opt/atomix; \ |
| 72 | tar zxmf /tmp/atomix.tar.gz -C /opt/atomix; \ |
| 73 | chown -R sdn:sdn /opt/atomix |
| 74 | |
| 75 | # Ports |
| 76 | # 22 - sshd |
| 77 | # 80 - supervisord |
| 78 | # 5678 - Atomix REST API |
| 79 | # 5679 - Atomix intra-cluster communication |
| 80 | # 6633 - OpenFlow legacy |
| 81 | # 6640 - OVSDB |
| 82 | # 6653 - OpenFlow IANA assigned |
| 83 | # 8101 - ONOS CLI |
| 84 | # 8181 - ONOS GUI |
| 85 | # 9876 - ONOS intra-cluster communication |
| 86 | EXPOSE 22 5678 5679 6633 6640 6653 8101 8181 9876 |
| 87 | #EXPOSE 80 |
| 88 | |
| 89 | CMD ["/usr/bin/supervisord", "-n"] |