This repository has been archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
145 lines (133 loc) · 5.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
FROM centos:7
LABEL maintainer="Håkon Strandenes <h.strandenes@km-turbulenz.no>"
LABEL description="LLVM+OSMesa compiled from sources"
# Note: "yum check-update" return code 100 if there are packages to be updated,
# hence the ";" instead of "&&"
RUN yum check-update ; \
yum -y install epel-release && \
yum -y update && \
yum -y install wget unzip centos-release-scl patchelf zlib-devel bison flex binutils-devel patch perl-Data-Dumper && \
yum -y install rh-python38 rh-python38-python-devel \
llvm-toolset-7.0 llvm-toolset-7.0-clang \
rh-git227 && \
yum clean all
# Python 3.8 package installation along with basic packages
RUN mkdir -p /opt/python38
COPY requirements.txt /opt/python38/
RUN source scl_source enable rh-python38 && \
cd /opt/python38 && \
python -m venv . && \
source bin/activate && \
pip install -r requirements.txt
# Fetch and install updated CMake in /usr/local
ENV CMAKE_VER="3.23.3"
ARG CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-x86_64.tar.gz"
RUN mkdir /tmp/cmake-install && \
cd /tmp/cmake-install && \
wget --no-verbose $CMAKE_URL && \
tar -xf cmake-${CMAKE_VER}-linux-x86_64.tar.gz -C /usr/local --strip-components=1 && \
cd / && \
rm -rf /tmp/cmake-install
# Fetch and install updated Ninja-build in /usr/local
ARG NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.11.0/ninja-linux.zip"
RUN mkdir /tmp/ninja-install && \
cd /tmp/ninja-install && \
wget --no-verbose $NINJA_URL && \
unzip ninja-linux.zip -d /usr/local/bin && \
cd / && \
rm -rf /tmp/ninja-install
# Download LLVM sources
ENV LLVM_VER="14.0.6"
ARG LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/llvm-project-${LLVM_VER}.src.tar.xz"
RUN set -o pipefail && \
mkdir -p /opt/llvm-build && \
cd /opt/llvm-build && \
wget --no-verbose $LLVM_URL && \
tar -xf llvm-project-${LLVM_VER}.src.tar.xz && \
rm llvm-project-${LLVM_VER}.src.tar.xz
# Compile LLVM + Clang compilation using LLVM-7 from Centos SCL
RUN set -o pipefail && \
source scl_source enable llvm-toolset-7.0 && \
source scl_source enable rh-python38 && \
cd /opt/llvm-build/llvm-project-${LLVM_VER}.src && \
mkdir build && \
cd build && \
cmake -GNinja \
-DLLVM_ENABLE_PROJECTS="clang;lld;openmp" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="/usr/local" \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
../llvm 2>&1 | tee cmake.log && \
ninja 2>&1 | tee ninja.log && \
ninja install 2>&1 | tee ninja_install.log && \
cd .. && \
rm -rf build
# CPU architecture for optimizations
ARG CPU_ARCH="x86-64-v2"
ENV CFLAGS="-march=${CPU_ARCH}"
ENV CXXFLAGS="-march=${CPU_ARCH}"
# LLVM stage 2 compilation - building LLVM and libLLVM with x86-64-v2
# architecture flag
RUN set -o pipefail && \
source scl_source enable rh-python38 && \
cd /opt/llvm-build/llvm-project-${LLVM_VER}.src/ && \
mkdir build-stage2 && \
cd build-stage2 && \
cmake -GNinja \
-DLLVM_ENABLE_PROJECTS="clang;lld;openmp" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="/usr/local" \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
../llvm 2>&1 | tee cmake.log && \
ninja 2>&1 | tee ninja.log && \
ninja install 2>&1 | tee ninja_install.log && \
cd .. && \
rm -rf build-stage2
# Download Mesa3D library
ENV MESA_VER="22.1.7"
ARG MESA_URL="https://archive.mesa3d.org/mesa-${MESA_VER}.tar.xz"
RUN mkdir -p /opt/mesa && \
cd /opt/mesa && \
wget --no-verbose $MESA_URL && \
tar -xf mesa-${MESA_VER}.tar.xz && \
rm mesa-${MESA_VER}.tar.xz
# Compile OSMesa
RUN set -o pipefail && \
source scl_source enable rh-python38 && \
source /opt/python38/bin/activate && \
cd /opt/mesa/mesa-${MESA_VER} && \
mkdir build && \
meson build \
-Dbuildtype=release \
-Dosmesa=true \
-Dgallium-drivers=swrast \
-Dglx=disabled \
-Ddri3=disabled \
-Degl=disabled \
-Ddri-drivers=[] \
-Dvulkan-drivers=[] \
-Dplatforms= \
-Dshared-llvm=false \
-Dshared-glapi=disabled \
-Dlibunwind=disabled \
-Dprefix=/usr/local 2>&1 | tee cmake.log && \
ninja -C build install 2>&1 | tee ninja.log && \
rm -rf build
ENV OSMESA_ROOT="/usr/local"
# Thread Building Blocks (TBB) download and unpack
ARG TBB_VER="2021.5.0"
ARG TBB_URL="https://github.com/oneapi-src/oneTBB/releases/download/v2021.5.0/oneapi-tbb-2021.5.0-lin.tgz"
RUN mkdir /opt/TBB && \
cd /opt/TBB && \
wget --no-verbose $TBB_URL && \
tar -xf oneapi-tbb-${TBB_VER}-lin.tgz && \
rm oneapi-tbb-${TBB_VER}-lin.tgz
ENV TBB_ROOT="/opt/TBB/oneapi-tbb-${TBB_VER}"