neomantra / docker-onload

Docker tooling for Solarflare's OpenOnload
https://hub.docker.com/r/neomantra/onload/
MIT License
25 stars 9 forks source link

Add Alpine #5

Closed holmesb closed 3 years ago

holmesb commented 4 years ago

Would be cool to add the Alpine thin-Linux distro. Widely-used Docker images are based on this. It uses the APK package manager. Busybox has no package manager so probably trickier\more work.

neomantra commented 4 years ago

I've tried this a few times over the years. Since Alpine isn't quite regular Linux, OpenOnload doesn't build on it. Better off sticking to Solarflare's supported Linux distros and making the images smaller (#4).

neomantra commented 4 years ago

Here's something to start with if you wanted to play around:

# Dockerfile - Ubuntu Bionic Beaver
#
# Installs Solarflare's OpenOnload into Alpine Linux.
#
# OpenOnload web page:
#    https://www.openonload.org/
#
# To expose the host and onload to this container, run like this:
#
#   docker run --net=host --device=/dev/onload --device=/dev/onload_epoll --device=/dev/onload_cplane -it ONLOAD_ENABLED_IMAGE_ID [COMMAND] [ARG...]
#
# NOTE: The host's OpenOnload version must be the same as the container's.
#
# Copyright (c) 2020 Neomantra BV
# Released under the MIT License, see LICENSE.txt
#

ARG ONLOAD_ALPINE_BASE="alpine"
ARG ONLOAD_ALPINE_TAG="3.11"

FROM ${ONLOAD_ALPINE_BASE}:${ONLOAD_ALPINE_TAG}

ARG ONLOAD_ALPINE_BASE="alpine"
ARG ONLOAD_ALPINE_TAG="3.11"

# Onload version and its md5sum
ARG ONLOAD_VERSION="7.0.0.176"
ARG ONLOAD_MD5SUM="851ccf4fc76c96bcbeb01e1c57b20cce"

# Onload package URL and legacy URL
# If ONLOAD_PACKAGE_URL is set, it will download and unzip the tarball from the newer packaging,
# otherwise it will download the tarball from ONLOAD_LEGACY_URL as before.
ARG ONLOAD_PACKAGE_URL="https://support.solarflare.com/index.php/component/cognidox/?task=download&file=SF-122921-DH-1.xml&subdoc=SF-109585-LS&subissue=32&o=1&format=raw"
ARG ONLOAD_LEGACY_URL="https://www.openonload.org/download/openonload-${ONLOAD_VERSION}.tgz"

# When ONLOAD_WITHZF is non-empty, the build includes Solarflare's TCPDirect library.
# Default is to exclude it.
ARG ONLOAD_WITHZF

# When ONLOAD_DISABLE_SYSCALL_HOOK is non-empty, then the build disables hooking the syscall function from libc.
# Default is empty, enabling the OpenOnload's default hooking the syscall function.
#
# This only works with OpenOnload 201811 and newer.
#
# Some libraries, such as jemalloc need to invoke syscalls at startup.
# This can cause infinite loops because the OpenOnload acceleration also needs malloc (via dlsym)
#    https://github.com/jemalloc/jemalloc/issues/443
#    https://github.com/jemalloc/jemalloc/issues/1426
ARG ONLOAD_DISABLE_SYSCALL_HOOK

# When ONLOAD_USERSPACE_ID is non-empty, it sets the userspace build md5sum ID.
# Default is empty, using the actual build md5sum ID
#
# This is necessary when the OpenOnload build is patched (for example with ONLOAD_DISABLE_SYSCALL_HOOK).
# The OpenOnload system checks for version and ID matches between userspace and the driver;
# thus one may need to spoof the userspace ID.
ARG ONLOAD_USERSPACE_ID

# 1) Install OpenOnload build dependencies
# 2) Download and verify OpenOnload from Solarflare's site
# 3) Extract, build, and install onload
# 4) Cleanup

RUN \
    apk add --no-cache --virtual .build-deps \
        autoconf \
        automake \
        libtool \
        libc-dev \
        libc6-compat \
        coreutils \
        patch \
        libpcap-dev \
        gcc \
        ca-certificates \
        curl \
        ethtool \
        kmod \
        net-tools \
        make \
        perl \
        sed \
        python3-dev \
        tar \
        valgrind \
        unzip \
    && cd /tmp \
    && if [ -n "${ONLOAD_PACKAGE_URL}" ] ; then \
          curl -fSL "${ONLOAD_PACKAGE_URL}" -o /tmp/onload-${ONLOAD_VERSION}-package.zip \
          && unzip /tmp/onload-${ONLOAD_VERSION}-package.zip \
          && echo "${ONLOAD_MD5SUM} onload-${ONLOAD_VERSION}.tgz" | md5sum --check \
          && tar -zxf onload-${ONLOAD_VERSION}.tgz ; \
    else \
          curl -fSL "${ONLOAD_LEGACY_URL}" -o /tmp/onload-${ONLOAD_VERSION}.tgz \
          && echo "${ONLOAD_MD5SUM} onload-${ONLOAD_VERSION}.tgz" | md5sum --check \
          && tar -zxf onload-${ONLOAD_VERSION}.tgz \
          && mv openonload-${ONLOAD_VERSION} onload-${ONLOAD_VERSION}; \
    fi \
    && cd /tmp/onload-${ONLOAD_VERSION} \
    && if [ -n "${ONLOAD_DISABLE_SYSCALL_HOOK}" ] ; then \
        echo 'ONLOAD_DISABLE_SYSCALL_HOOK set, disabling CI_CFG_USERSPACE_SYSCALL' \
        && sed -i 's/#define CI_CFG_USERSPACE_SYSCALL        1/#define CI_CFG_USERSPACE_SYSCALL        0 \/\/ disabled by ONLOAD_DISABLE_SYSCALL_HOOK/' ./src/include/ci/internal/transport_config_opt.h ; \
    fi \
    && if [ -n "${ONLOAD_USERSPACE_ID}" ] ; then \
        echo "ONLOAD_USERSPACE_ID set, applying userspace interface id '${ONLOAD_USERSPACE_ID}'" \
        && sed -i "s/\$\$md5/${ONLOAD_USERSPACE_ID}/" src/lib/transport/ip/mmake.mk ; \
    fi

RUN cd /tmp/onload-${ONLOAD_VERSION} \
    && cd scripts \
    && ./onload_build --user \
    && ./onload_install --userfiles --nobuild \
    && cd /tmp \
    && rm -rf onload-${ONLOAD_VERSION}* \
    && if [ -z ${ONLOAD_WITHZF} ] ; then \
        rm -rf /usr/include/zf /usr/bin/zf_stackdump /usr/bin/zf_debug /usr/lib/x86_64-linux-gnu/zf /usr/lib/x86_64-linux-gnu/libonload_zf* ; \
    fi

# Labels for introspection
LABEL maintainer="Evan Wies <evan@neomantra.net>"
LABEL ONLOAD_ALPINE_BASE="${ONLOAD_ALPINE_BASE}"
LABEL ONLOAD_ALPINE_TAG="${ONLOAD_ALPINE_TAG}"
LABEL ONLOAD_PACKAGE_URL="${ONLOAD_PACKAGE_URL}"
LABEL ONLOAD_LEGACY_URL="${ONLOAD_LEGACY_URL}"
LABEL ONLOAD_VERSION="${ONLOAD_VERSION}"
LABEL ONLOAD_MD5SUM="${ONLOAD_MD5SUM}"
LABEL ONLOAD_WITHZF="${ONLOAD_WITHZF}"
LABEL ONLOAD_DISABLE_SYSCALL_HOOK="${ONLOAD_DISABLE_SYSCALL_HOOK}"
LABEL ONLOAD_USERSPACE_ID="${ONLOAD_USERSPACE_ID}"
neomantra commented 3 years ago

Closing as wontfix unless upstream adds support for Alpine.