|
| 1 | +# Dockerfile.ubuntu |
| 2 | +# |
| 3 | +# This file acts partly as a Docker recipe for building Cloe on Ubuntu. |
| 4 | +# It is currently only tested with Ubuntu 16.04. |
| 5 | +# |
| 6 | +# If you are behind a proxy, make sure to pass in the respective HTTP_PROXY, |
| 7 | +# HTTPS_PROXY, and NO_PROXY variables. |
| 8 | +ARG BUILD_FROM=ubuntu:16.04 |
| 9 | +ARG DEPLOY_FROM=${BUILD_FROM} |
| 10 | + |
| 11 | +FROM ${BUILD_FROM} AS build |
| 12 | + |
| 13 | +# Install Newer CMake and GCC Packages |
| 14 | +RUN apt-get update && \ |
| 15 | + apt-get install --no-install-recommends -y apt-transport-https ca-certificates gnupg software-properties-common wget && \ |
| 16 | + # Add cmake repository: |
| 17 | + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - > /etc/apt/trusted.gpg.d/kitware.gpg && \ |
| 18 | + apt-add-repository "deb https://apt.kitware.com/ubuntu/ xenial main" && \ |
| 19 | + add-apt-repository "ppa:ubuntu-toolchain-r/test" && \ |
| 20 | + # Install packages: |
| 21 | + apt-get update && \ |
| 22 | + export DEBIAN_FRONTEND=noninteractive && \ |
| 23 | + apt-get install --no-install-recommends -y gcc-8 g++-8 cmake && \ |
| 24 | + rm -rf /var/lib/apt/lists/* |
| 25 | + |
| 26 | +# Install Pyenv |
| 27 | +RUN apt-get update && \ |
| 28 | + apt-get install --no-install-recommends -y \ |
| 29 | + build-essential \ |
| 30 | + curl \ |
| 31 | + git \ |
| 32 | + libbz2-dev \ |
| 33 | + libffi-dev \ |
| 34 | + liblzma-dev \ |
| 35 | + libncurses5-dev \ |
| 36 | + libreadline-dev \ |
| 37 | + libsqlite3-dev \ |
| 38 | + libssl-dev \ |
| 39 | + libxml2-dev \ |
| 40 | + libxmlsec1-dev \ |
| 41 | + llvm \ |
| 42 | + make \ |
| 43 | + tk-dev \ |
| 44 | + wget \ |
| 45 | + xz-utils \ |
| 46 | + zlib1g-dev \ |
| 47 | + && \ |
| 48 | + curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash && \ |
| 49 | + echo 'export PATH="/root/.pyenv/bin:$PATH"' >> /etc/profile.d/pyenv.sh && \ |
| 50 | + echo 'eval "$(pyenv init --path)"' >> /etc/profile.d/pyenv.sh && \ |
| 51 | + echo 'eval "$(pyenv init -)"' >> /etc/profile.d/pyenv.sh && \ |
| 52 | + echo 'eval "$(pyenv virtualenv-init -)"' >> /etc/profile.d/pyenv.sh && \ |
| 53 | + rm -rf /var/lib/apt/lists/* |
| 54 | + |
| 55 | +ARG PYTHON_VERSION=3.6.13 |
| 56 | +RUN . /etc/profile.d/pyenv.sh && \ |
| 57 | + pyenv install ${PYTHON_VERSION} && \ |
| 58 | + pyenv global ${PYTHON_VERSION} |
| 59 | + |
| 60 | +# Install System Packages |
| 61 | +# |
| 62 | +# These packages are required for building and testing Cloe. |
| 63 | +COPY Makefile.setup /cloe/Makefile.setup |
| 64 | +RUN apt-get update && \ |
| 65 | + apt-get install -y make locales && \ |
| 66 | + make -f /cloe/Makefile.setup \ |
| 67 | + WITHOUT_DEV_DEPS=yes \ |
| 68 | + DEBIAN_FRONTEND=noninteractive \ |
| 69 | + APT_ARGS="--no-install-recommends -y" \ |
| 70 | + install-system-deps \ |
| 71 | + && \ |
| 72 | + locale-gen en_US.UTF-8 && \ |
| 73 | + rm -rf /var/lib/apt/lists/* |
| 74 | + |
| 75 | +RUN . /etc/profile.d/pyenv.sh && \ |
| 76 | + pip install --upgrade pip && \ |
| 77 | + make -f /cloe/Makefile.setup \ |
| 78 | + PIP_INSTALL_ARGS="" \ |
| 79 | + install-python-deps |
| 80 | + |
| 81 | +# Install and Setup Conan |
| 82 | +# |
| 83 | +# You may not want to use the default Conan remote (conan-center), so we use |
| 84 | +# whatever is stored in the build arguments CONAN_REMOTE. Currently, only |
| 85 | +# anonymous access is possible in this Dockerfile. |
| 86 | +ARG CONAN_REMOTE=https://conan.bintray.com |
| 87 | +ARG CONAN_REMOTE_VERIFY_SSL=true |
| 88 | +RUN . /etc/profile.d/pyenv.sh && \ |
| 89 | + conan profile new --detect default && \ |
| 90 | + conan profile update settings.compiler.libcxx=libstdc++11 default && \ |
| 91 | + conan config set general.request_timeout=360 && \ |
| 92 | + conan remote clean && \ |
| 93 | + conan remote add default ${CONAN_REMOTE} ${CONAN_REMOTE_VERIFY_SSL} |
| 94 | + |
| 95 | +# Build and Install Cloe |
| 96 | +# |
| 97 | +# All common processes are made easy to apply by writing target recipes in the |
| 98 | +# Makefile at the root of the repository. This also acts as a form of |
| 99 | +# documentation. |
| 100 | +WORKDIR /cloe |
| 101 | +COPY . /cloe |
| 102 | +ARG WITH_VTD=0 |
| 103 | +ARG PACKAGE_TARGET=package-select |
| 104 | +RUN . /etc/profile.d/pyenv.sh && \ |
| 105 | + # Export our own Conan recipes, in case they are not available in the |
| 106 | + # CONAN_REMOTE specified above. |
| 107 | + make export-vendor export && \ |
| 108 | + # Build all the packages, except for vtd, because that currently requires |
| 109 | + # dependencies we don't have in the Docker container. |
| 110 | + # You can specify more than one package here, see the Makefile for more |
| 111 | + # information on the WITH_*, PACKAGES, NOBUILD_PKGS, and BUILD_PKGS variables. |
| 112 | + make WITH_VTD=${WITH_VTD} ${PACKAGE_TARGET} && \ |
| 113 | + # In the above commands, Conan downloads and creates packages into its |
| 114 | + # local cache. We don't need the build directories, since we have deployed |
| 115 | + # Cloe, so we should clean up to keep the Docker image down. |
| 116 | + conan remove \* -b -f |
| 117 | + |
| 118 | +RUN . /etc/profile.d/pyenv.sh && \ |
| 119 | + # Run smoketests. |
| 120 | + export LC_ALL=C.UTF-8 LANG=C.UTF-8 && \ |
| 121 | + make WITH_VTD=${WITH_VTD} smoketest && \ |
| 122 | + # Deploy all the Cloe packages to INSTALL_DIR, which is /usr/local by |
| 123 | + # default. This will also populate BUILD_DIR, so that should be removed |
| 124 | + # afterwards to prevent this image from getting too big. |
| 125 | + make WITH_VTD=${WITH_VTD} INSTALL_DIR="/deploy" deploy |
| 126 | + |
| 127 | +# Create Deploy Image |
| 128 | +# |
| 129 | +# Unfortunately, there are still some issues with cloe-engine not finding |
| 130 | +# libcloe-runtime.so, so we need to explicitly set LD_LIBRARY_PATH. |
| 131 | +# |
| 132 | +# This image can now be used to work with stack files. You should mount in |
| 133 | +# whatever directory contains your stack files for best results, otherwise |
| 134 | +# the engine might try to read files that it doesn't have in its own filesystem. |
| 135 | +FROM ${DEPLOY_FROM} |
| 136 | +COPY --from=build /deploy /usr/local/ |
| 137 | +ENV LD_LIBRARY_PATH=/usr/local/lib |
| 138 | +ENTRYPOINT [ "cloe-engine" ] |
0 commit comments