From 54dc7e6881a1b1c7a38cef9c2af62b972ceec06a Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Fri, 17 Nov 2023 12:03:26 -0800 Subject: [PATCH] install: streamlines dockerfiles to focus on using and pulling built packages from latest release, improvements to space used during build and emane python bindings --- dockerfiles/Dockerfile.centos | 79 -------------------- dockerfiles/Dockerfile.centos-package | 93 ----------------------- dockerfiles/Dockerfile.emane-python | 40 ++++++++++ dockerfiles/Dockerfile.ospf-mdr | 33 +++++++++ dockerfiles/Dockerfile.rocky | 80 ++++++++++++++++++++ dockerfiles/Dockerfile.ubuntu | 102 +++++++++++++++----------- dockerfiles/Dockerfile.ubuntu-package | 84 --------------------- docs/install_docker.md | 16 ++-- 8 files changed, 219 insertions(+), 308 deletions(-) delete mode 100644 dockerfiles/Dockerfile.centos delete mode 100644 dockerfiles/Dockerfile.centos-package create mode 100644 dockerfiles/Dockerfile.emane-python create mode 100644 dockerfiles/Dockerfile.ospf-mdr create mode 100644 dockerfiles/Dockerfile.rocky delete mode 100644 dockerfiles/Dockerfile.ubuntu-package diff --git a/dockerfiles/Dockerfile.centos b/dockerfiles/Dockerfile.centos deleted file mode 100644 index f068951d..00000000 --- a/dockerfiles/Dockerfile.centos +++ /dev/null @@ -1,79 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM centos:7 -LABEL Description="CORE Docker CentOS Image" - -ENV LANG en_US.UTF-8 - -# install system dependencies -RUN yum -y update && \ - yum install -y \ - psmisc \ - sysvinit-tools \ - xterm \ - git \ - sudo \ - wget \ - tzdata \ - unzip \ - libpcap-devel \ - libpcre3-devel \ - libxml2-devel \ - protobuf-devel \ - unzip \ - uuid-devel \ - tcpdump \ - make && \ - yum-builddep -y python3 && \ - yum autoremove -y && \ - yum install -y hostname - -# install python3.9 -WORKDIR /opt -RUN wget https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tgz && \ - tar xf Python-3.9.15.tgz && \ - cd Python-3.9.15 && \ - ./configure --enable-optimizations --with-ensurepip=install && \ - make -j$(nproc) altinstall && \ - python3.9 -m pip install --upgrade pip && \ - cd /opt && \ - rm -rf Python-3.9.15 - -# install core -ARG PREFIX=/usr -ARG BRANCH=master -RUN git clone https://github.com/coreemu/core && \ - cd core && \ - git checkout ${BRANCH} && \ - NO_SYSTEM=1 PYTHON=/usr/local/bin/python3.9 ./setup.sh && \ - PATH=/root/.local/bin:$PATH PYTHON=/usr/local/bin/python3.9 inv install -v -p ${PREFIX} --no-python - -# install emane -RUN wget -q https://adjacentlink.com/downloads/emane/emane-1.3.3-release-1.el7.x86_64.tar.gz && \ - tar xf emane-1.3.3-release-1.el7.x86_64.tar.gz && \ - cd emane-1.3.3-release-1/rpms/el7/x86_64 && \ - yum install -y epel-release && \ - yum install -y ./openstatistic*.rpm ./emane*.rpm ./python3-emane_*.rpm && \ - cd ../../../.. && \ - rm emane-1.3.3-release-1.el7.x86_64.tar.gz && \ - rm -rf emane-1.3.3-release-1 - -# install emane python bindings -ARG VENV_PATH=/opt/core/venv -ARG PROTOC_VERSION=3.19.6 -RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ - mkdir protoc && \ - unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc && \ - git clone https://github.com/adjacentlink/emane.git && \ - cd emane && \ - git checkout v1.3.3 && \ - ./autogen.sh && \ - PYTHON=${VENV_PATH}/bin/python ./configure --prefix=/usr && \ - cd src/python && \ - PATH=/opt/protoc/bin:$PATH make && \ - ${VENV_PATH}/bin/python -m pip install . && \ - cd /opt && \ - rm -rf protoc && \ - rm -rf emane && \ - rm -f protoc-${PROTOC_VERSION}-linux-x86_64.zip - -WORKDIR /root diff --git a/dockerfiles/Dockerfile.centos-package b/dockerfiles/Dockerfile.centos-package deleted file mode 100644 index 04cff0d2..00000000 --- a/dockerfiles/Dockerfile.centos-package +++ /dev/null @@ -1,93 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM centos:7 -LABEL Description="CORE CentOS Image" - -ENV LANG en_US.UTF-8 - -# install basic dependencies -RUN yum -y update && \ - yum install -y \ - psmisc \ - sysvinit-tools \ - xterm \ - git \ - sudo \ - wget \ - tzdata \ - unzip \ - libpcap-devel \ - libpcre3-devel \ - libxml2-devel \ - protobuf-devel \ - unzip \ - uuid-devel \ - tcpdump \ - automake \ - gawk \ - libreadline-devel \ - libtool \ - pkg-config \ - make && \ - yum-builddep -y python3 && \ - yum autoremove -y && \ - yum install -y hostname - -# install python3.9 -WORKDIR /opt -RUN wget https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tgz && \ - tar xf Python-3.9.15.tgz && \ - cd Python-3.9.15 && \ - ./configure --enable-optimizations --with-ensurepip=install && \ - make -j$(nproc) altinstall && \ - python3.9 -m pip install --upgrade pip && \ - cd /opt && \ - rm -rf Python-3.9.15 - -# install core -ARG PACKAGE_URL=https://github.com/coreemu/core/releases/latest/download/core_9.0.3_x86_64.rpm -RUN wget ${PACKAGE_URL} && \ - PYTHON=/usr/local/bin/python3.9 yum install -y ./core_*.rpm && \ - rm -f core_*.rpm - -# install ospf mdr -RUN git clone https://github.com/USNavalResearchLaboratory/ospf-mdr.git && \ - cd ospf-mdr && \ - ./bootstrap.sh && \ - ./configure --disable-doc --enable-user=root --enable-group=root \ - --with-cflags=-ggdb --sysconfdir=/usr/local/etc/quagga --enable-vtysh \ - --localstatedir=/var/run/quagga && \ - make -j$(nproc) && \ - make install && \ - cd /opt && \ - rm -rf ospf-mdr - - # install emane -RUN wget -q https://adjacentlink.com/downloads/emane/emane-1.3.3-release-1.el7.x86_64.tar.gz && \ - tar xf emane-1.3.3-release-1.el7.x86_64.tar.gz && \ - cd emane-1.3.3-release-1/rpms/el7/x86_64 && \ - yum install -y epel-release && \ - yum install -y ./openstatistic*.rpm ./emane*.rpm ./python3-emane_*.rpm && \ - cd ../../../.. && \ - rm emane-1.3.3-release-1.el7.x86_64.tar.gz && \ - rm -rf emane-1.3.3-release-1 - -# install emane python bindings -ARG VENV_PATH=/opt/core/venv -ARG PROTOC_VERSION=3.19.6 -RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ - mkdir protoc && \ - unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc && \ - git clone https://github.com/adjacentlink/emane.git && \ - cd emane && \ - git checkout v1.3.3 && \ - ./autogen.sh && \ - PYTHON=${VENV_PATH}/bin/python ./configure --prefix=/usr && \ - cd src/python && \ - PATH=/opt/protoc/bin:$PATH make && \ - ${VENV_PATH}/bin/python -m pip install . && \ - cd /opt && \ - rm -rf protoc && \ - rm -rf emane && \ - rm -f protoc-${PROTOC_VERSION}-linux-x86_64.zip - -WORKDIR /root diff --git a/dockerfiles/Dockerfile.emane-python b/dockerfiles/Dockerfile.emane-python new file mode 100644 index 00000000..ada90278 --- /dev/null +++ b/dockerfiles/Dockerfile.emane-python @@ -0,0 +1,40 @@ +# syntax=docker/dockerfile:1 +FROM ubuntu:22.04 +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + automake \ + ca-certificates \ + g++ \ + git \ + libpcap-dev \ + libpcre3-dev \ + libprotobuf-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + python3 \ + python3-pip \ + unzip \ + uuid-dev \ + wget && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* +WORKDIR /opt +ARG PROTOC_VERSION=3.19.6 +RUN wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ + mkdir protoc && \ + unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc && \ + git clone https://github.com/adjacentlink/emane.git && \ + cd emane && \ + git checkout v1.5.1 && \ + ./autogen.sh && \ + PYTHON=python3 ./configure --prefix=/usr && \ + cd src/python && \ + PATH=/opt/protoc/bin:$PATH make && \ + python3 setup.py bdist_wheel && \ + mv dist/*.whl /opt/ && \ + cd /opt && \ + rm -rf protoc && \ + rm -rf emane && \ + rm -f protoc-${PROTOC_VERSION}-linux-x86_64.zip diff --git a/dockerfiles/Dockerfile.ospf-mdr b/dockerfiles/Dockerfile.ospf-mdr new file mode 100644 index 00000000..948689e9 --- /dev/null +++ b/dockerfiles/Dockerfile.ospf-mdr @@ -0,0 +1,33 @@ +# syntax=docker/dockerfile:1 +FROM ubuntu:18.04 as ospf-mdr +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + automake \ + build-essential:native \ + ca-certificates \ + debhelper \ + dpkg-dev \ + fakeroot \ + g++ \ + gawk \ + git \ + groff \ + imagemagick \ + libreadline-dev \ + libtool \ + make \ + texinfo \ + texlive-generic-recommended \ + texlive-latex-base \ + pkg-config && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* +WORKDIR /opt +RUN git clone https://github.com/USNavalResearchLaboratory/ospf-mdr.git && \ + cd ospf-mdr && \ + ./bootstrap.sh && \ + ./configure && \ + make -j$(nproc) && \ + make -f quagga.deb.mk build || true + cd /opt && \ + rm -rf ospf-mdr diff --git a/dockerfiles/Dockerfile.rocky b/dockerfiles/Dockerfile.rocky new file mode 100644 index 00000000..0081ae6a --- /dev/null +++ b/dockerfiles/Dockerfile.rocky @@ -0,0 +1,80 @@ +# syntax=docker/dockerfile:1 +FROM rockylinux:8 +ENV LANG en_US.UTF-8 + +# install system dependencies +RUN yum update -y && \ + yum install -y \ + xterm \ + wget \ + tcpdump \ + python39 \ + python39-tkinter \ + iproute-tc && \ + yum autoremove -y && \ + yum clean all + +# install ospf mdr +RUN yum update -y && \ + yum install -y \ + automake \ + gcc-c++ \ + libtool \ + make \ + pkg-config \ + readline-devel \ + git && \ + git clone https://github.com/USNavalResearchLaboratory/ospf-mdr.git && \ + cd ospf-mdr && \ + ./bootstrap.sh && \ + ./configure --disable-doc --enable-user=root --enable-group=root \ + --with-cflags=-ggdb --sysconfdir=/usr/local/etc/quagga --enable-vtysh \ + --localstatedir=/var/run/quagga && \ + make -j$(nproc) && \ + make install && \ + cd /opt && \ + rm -rf ospf-mdr && \ + yum remove -y \ + automake \ + gcc-c++ \ + libtool \ + make \ + pkg-config \ + readline-devel \ + git && \ + yum autoremove -y --skip-broken && \ + yum clean all + +# install emane +ARG EMANE_VERSION=1.5.1 +ARG EMANE_RELEASE=emane-${EMANE_VERSION}-release-1 +ARG EMANE_PACKAGE=${EMANE_RELEASE}.el8.x86_64.tar.gz +RUN yum update -y && \ + wget -q https://adjacentlink.com/downloads/emane/${EMANE_PACKAGE} && \ + tar xf ${EMANE_PACKAGE} && \ + cd ${EMANE_RELEASE}/rpms/el8/x86_64 && \ + rm emane-spectrum-tools-*.rpm emane-model-lte*.rpm && \ + rm *devel*.rpm && \ + yum install -y ./emane*.rpm ./python3-emane-${EMANE_VERSION}-1.el8.noarch.rpm && \ + cd ../../../.. && \ + rm ${EMANE_PACKAGE} && \ + rm -rf ${EMANE_RELEASE} && \ + yum autoremove -y && \ + yum clean all + +# install core +WORKDIR /opt +ARG PACKAGE_URL=https://github.com/coreemu/core/releases/latest/download/core_9.0.3_x86_64.rpm +RUN yum update -y && \ + wget -q ${PACKAGE_URL} && \ + PYTHON=python3.9 yum install -y ./core_*.rpm && \ + rm -f core_*.rpm && \ + yum autoremove -y && \ + yum clean all + +# install emane python bindings +ARG VENV_PATH=/opt/core/venv +COPY --from=emane-python /opt/emane-*.whl . +RUN ${VENV_PATH}/bin/python -m pip install ./emane-*.whl + +WORKDIR /root diff --git a/dockerfiles/Dockerfile.ubuntu b/dockerfiles/Dockerfile.ubuntu index 8a790f66..d22cde5b 100644 --- a/dockerfiles/Dockerfile.ubuntu +++ b/dockerfiles/Dockerfile.ubuntu @@ -1,69 +1,87 @@ # syntax=docker/dockerfile:1 FROM ubuntu:22.04 -LABEL Description="CORE Docker Ubuntu Image" - ENV DEBIAN_FRONTEND=noninteractive # install system dependencies RUN apt-get update -y && \ apt-get install -y --no-install-recommends \ ca-certificates \ - git \ - sudo \ + xterm \ + psmisc \ + python3 \ + python3-tk \ + python3-pip \ + python3-venv \ wget \ - tzdata \ - libpcap-dev \ - libpcre3-dev \ - libprotobuf-dev \ - libxml2-dev \ - protobuf-compiler \ - unzip \ - uuid-dev \ iproute2 \ iputils-ping \ tcpdump && \ - apt-get autoremove -y + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* -# install core -WORKDIR /opt -ARG PREFIX=/usr/local -ARG BRANCH=master -RUN git clone https://github.com/coreemu/core && \ - cd core && \ - git checkout ${BRANCH} && \ - ./setup.sh && \ - PATH=/root/.local/bin:$PATH inv install -v -p ${PREFIX} && \ +# install ospf mdr +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + automake \ + gawk \ + g++ \ + libreadline-dev \ + libtool \ + make \ + pkg-config \ + git && \ + git clone https://github.com/USNavalResearchLaboratory/ospf-mdr.git && \ + cd ospf-mdr && \ + ./bootstrap.sh && \ + ./configure --disable-doc --enable-user=root --enable-group=root \ + --with-cflags=-ggdb --sysconfdir=/usr/local/etc/quagga --enable-vtysh \ + --localstatedir=/var/run/quagga && \ + make -j$(nproc) && \ + make install && \ cd /opt && \ - rm -rf ospf-mdr + rm -rf ospf-mdr && \ + apt-get remove -y \ + automake \ + gawk \ + g++ \ + libreadline-dev \ + libtool \ + make \ + pkg-config \ + git && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* # install emane ARG EMANE_RELEASE=emane-1.5.1-release-1 ARG EMANE_PACKAGE=${EMANE_RELEASE}.ubuntu-22_04.amd64.tar.gz -RUN wget -q https://adjacentlink.com/downloads/emane/${EMANE_PACKAGE} && \ +RUN apt-get update -y && \ + wget -q https://adjacentlink.com/downloads/emane/${EMANE_PACKAGE} && \ tar xf ${EMANE_PACKAGE} && \ cd ${EMANE_RELEASE}/debs/ubuntu-22_04/amd64 && \ - apt-get install -y ./openstatistic*.deb ./emane*.deb ./python3-emane_*.deb && \ + rm emane-spectrum-tools*.deb emane-model-lte*.deb && \ + rm *dev*.deb && \ + apt-get install -y --no-install-recommends ./emane*.deb ./python3-emane_*.deb && \ cd ../../../.. && \ rm ${EMANE_PACKAGE} && \ - rm -rf ${EMANE_RELEASE} + rm -rf ${EMANE_RELEASE} && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* + +# install core +WORKDIR /opt +ARG CORE_PACKAGE=core_9.0.3_amd64.deb +ARG PACKAGE_URL=https://github.com/coreemu/core/releases/latest/download/${CORE_PACKAGE} +RUN apt-get update -y && \ + wget -q ${PACKAGE_URL} && \ + apt-get install -y --no-install-recommends ./${CORE_PACKAGE} && \ + rm -f ${CORE_PACKAGE} && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* # install emane python bindings ARG VENV_PATH=/opt/core/venv -ARG PROTOC_VERSION=3.19.6 -RUN wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ - mkdir protoc && \ - unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc && \ - git clone https://github.com/adjacentlink/emane.git && \ - cd emane && \ - git checkout v1.5.1 && \ - ./autogen.sh && \ - PYTHON=${VENV_PATH}/bin/python ./configure --prefix=/usr && \ - cd src/python && \ - PATH=/opt/protoc/bin:$PATH make && \ - ${VENV_PATH}/bin/python -m pip install . && \ - cd /opt && \ - rm -rf protoc && \ - rm -rf emane && \ - rm -f protoc-${PROTOC_VERSION}-linux-x86_64.zip +COPY --from=emane-python /opt/emane-*.whl . +RUN ${VENV_PATH}/bin/python -m pip install ./emane-*.whl WORKDIR /root diff --git a/dockerfiles/Dockerfile.ubuntu-package b/dockerfiles/Dockerfile.ubuntu-package deleted file mode 100644 index 1164b15e..00000000 --- a/dockerfiles/Dockerfile.ubuntu-package +++ /dev/null @@ -1,84 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM ubuntu:22.04 -LABEL Description="CORE Docker Ubuntu Image" - -ENV DEBIAN_FRONTEND=noninteractive - -# install basic dependencies -RUN apt-get update -y && \ - apt-get install -y --no-install-recommends \ - ca-certificates \ - python3 \ - python3-tk \ - python3-pip \ - python3-venv \ - libpcap-dev \ - libpcre3-dev \ - libprotobuf-dev \ - libxml2-dev \ - protobuf-compiler \ - unzip \ - uuid-dev \ - automake \ - gawk \ - git \ - wget \ - libreadline-dev \ - libtool \ - pkg-config \ - g++ \ - make \ - iputils-ping \ - tcpdump && \ - apt-get autoremove -y - -# install core -WORKDIR /opt -ARG PACKAGE_URL=https://github.com/coreemu/core/releases/latest/download/core_9.0.3_amd64.deb -RUN wget -q ${PACKAGE_URL} && \ - apt-get install -y ./core_*.deb && \ - rm -f core_*.deb - -# install ospf mdr -RUN git clone https://github.com/USNavalResearchLaboratory/ospf-mdr.git && \ - cd ospf-mdr && \ - ./bootstrap.sh && \ - ./configure --disable-doc --enable-user=root --enable-group=root \ - --with-cflags=-ggdb --sysconfdir=/usr/local/etc/quagga --enable-vtysh \ - --localstatedir=/var/run/quagga && \ - make -j$(nproc) && \ - make install && \ - cd /opt && \ - rm -rf ospf-mdr - -# install emane -ARG EMANE_RELEASE=emane-1.5.1-release-1 -ARG EMANE_PACKAGE=${EMANE_RELEASE}.ubuntu-22_04.amd64.tar.gz -RUN wget -q https://adjacentlink.com/downloads/emane/${EMANE_PACKAGE} && \ - tar xf ${EMANE_PACKAGE} && \ - cd ${EMANE_RELEASE}/debs/ubuntu-22_04/amd64 && \ - apt-get install -y ./openstatistic*.deb ./emane*.deb ./python3-emane_*.deb && \ - cd ../../../.. && \ - rm ${EMANE_PACKAGE} && \ - rm -rf ${EMANE_RELEASE} - -# install emane python bindings -ARG VENV_PATH=/opt/core/venv -ARG PROTOC_VERSION=3.19.6 -RUN wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \ - mkdir protoc && \ - unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc && \ - git clone https://github.com/adjacentlink/emane.git && \ - cd emane && \ - git checkout v1.5.1 && \ - ./autogen.sh && \ - PYTHON=${VENV_PATH}/bin/python ./configure --prefix=/usr && \ - cd src/python && \ - PATH=/opt/protoc/bin:$PATH make && \ - ${VENV_PATH}/bin/python -m pip install . && \ - cd /opt && \ - rm -rf protoc && \ - rm -rf emane && \ - rm -f protoc-${PROTOC_VERSION}-linux-x86_64.zip - -WORKDIR /root diff --git a/docs/install_docker.md b/docs/install_docker.md index 8e185451..e183fd7f 100644 --- a/docs/install_docker.md +++ b/docs/install_docker.md @@ -12,24 +12,20 @@ The example Dockerfiles are not meant to be an end all solution, but a solid sta Provided Dockerfiles: -* Dockerfile.centos - CentOS 7, CORE from source, OSPF MDR, and EMANE -* Dockerfile.centos-package - CentOS 7, CORE from local package, OSPF MDR, and EMANE -* Dockerfile.ubuntu - Ubuntu 22.04, CORE from source, OSPF MDR, and EMANE -* Dockerfile.ubuntu-package - Ubuntu 22.04, CORE from local package, OSPF MDR, and EMANE +* Dockerfile.emane-python - Build EMANE python bindings for use in files below +* Dockerfile.rocky - Rocky Linux 8, CORE from latest package, OSPF MDR, and EMANE +* Dockerfile.ubuntu - Ubuntu 22.04, CORE from latest package, OSPF MDR, and EMANE ```shell # clone core git clone https://github.com/coreemu/core.git -# build image +# first you must build EMANE python bindings +docker build -t emane-python -f dockerfiles/Dockerfile.emane-python . +# build desired CORE image cd core sudo docker build -t core -f dockerfiles/ . ``` -For the example files that build from source, you can have it build from develop or another branch. -```shell -sudo docker build -t core --build-arg BRANCH=develop -f dockerfiles/ . -``` - ## Run Container There are some required parameters when starting a CORE based Docker container for CORE to function properly. These