summaryrefslogtreecommitdiffstats
path: root/build/buildah-base.sh
blob: fcb320010223cbc94bb8d22bad5f5c47faa0f68c (plain)
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
#! /usr/bin/env bash

set -o errexit

tag=latest
[ -n "$1" ] && tag="$1"

#container=$(buildah from nvidia/cuda:10.1-devel-ubuntu18.04)
[ $tag == "20.04" ] && container=$(buildah from nvidia/cuda:11.3.0-devel-ubuntu20.04)
[ $tag == "22.04" ] && container=$(buildah from nvidia/cuda:11.7.1-devel-ubuntu22.04)
[ -n "$container" ] && container=$(buildah from nvidia/cuda:11.7.1-devel-ubuntu$tag)

buildah config --label maintainer="Suren A. Chilingaryan <csa@suren.me>" $container
buildah config --env LANG="C.UTF-8" --env LC_ALL="C.UTF-8" --env TERM="xterm" $container

buildah run $container ln -snf /usr/share/zoneinfo/Europe/London /etc/localtime
buildah run $container sh -c 'echo "Europe/London" > /etc/timezone'

buildah run $container sh -c 'echo "ssh:x:101:" >> /etc/group'
buildah run $container sh -c 'echo "sshd:x:101:101:sshd:/dev/null:/sbin/nologin" >> /etc/passwd'
buildah run $container sh -c 'echo "messagebus:x:102:" >> /etc/group'
buildah run $container sh -c 'echo "messagebus:x:102:102:messagebus:/dev/null:/sbin/nologin" >> /etc/passwd'
buildah run $container sh -c 'echo "rdma:x:103:" >> /etc/group'
buildah run $container sh -c 'echo "systemd-journal:x:104:" >> /etc/group'
buildah run $container sh -c 'echo "systemd-network:x:105:" >> /etc/group'
buildah run $container sh -c 'echo "systemd-network:x:105:105:systemd-network:/dev/null:/sbin/nologin" >> /etc/passwd'
buildah run $container sh -c 'echo "systemd-resolve:x:106:" >> /etc/group'
buildah run $container sh -c 'echo "systemd-resolve:x:106:106:systemd-resolve:/dev/null:/sbin/nologin" >> /etc/passwd'
buildah run $container sh -c 'echo "systemd-timesync:x:107:" >> /etc/group'
buildah run $container sh -c 'echo "systemd-timesync:x:107:107:systemd-timesync:/dev/null:/sbin/nologin" >> /etc/passwd'

# https://stackoverflow.com/questions/71941032/why-i-cannot-run-apt-update-inside-a-fresh-ubuntu22-04
buildah run $container sh -c 'sed -i -e "s/^APT/# APT/" -e "s/^DPkg/# DPkg/" /etc/apt/apt.conf.d/docker-clean'

buildah run $container sh -c 'apt-get update --fix-missing && apt-get install -y bash wget bzip2 mc rar ca-certificates git openssh-server'
buildah run $container sh -c 'apt-get install -y python3 python3-setuptools python3-pip cython3'
buildah run $container sh -c 'apt-get install -y cmake make autoconf automake libtool gcc g++ libboost-all-dev'

[ $tag == "22.04" ] && buildah run $container sh -c 'apt-get install -y gcc-12 g++-12'					# First gcc version supporting _Float16 data type
[ $tag != "20.04" ] && buildah run $container sh -c 'apt-get install -y screen perf-tools-unstable gdb htop'		# Debugging/Profilling tools
buildah run $container sh -c 'apt-get install -y ca-certificates pkg-config gobject-introspection liblapack-dev libjpeg-dev libtiff-dev libglib2.0-dev libjson-glib-dev libopenmpi-dev libhdf5-dev libclfft-dev libgsl-dev libgirepository1.0-dev fftw3-dev zlib1g-dev'

# Problems with python3-tifffile (this should be ran after installing pkgconfig/gobject stuff)
buildah run $container sh -c 'sed -i -e "s/^post-invoke/# post-invoke/" /etc/dpkg/dpkg.cfg.d/pkg-config-hook-config'

buildah run $container sh -c 'apt-get install -y python3-dev python3-numpy  python3-gi python3-gi-cairo python3-tifffile'

[ $tag != "20.04" ] && buildah run $container sh -c 'apt-get install -y python3-astropy python3-opencv python3-willow python3-pypillowfight python3-scipy python3-sklearn python3-skorch python3-tomopy'	# Not needed for ccpi/ufo, but rather additional image-processing code for python
buildah run $container sh -c 'apt-get install -y ocl-icd-opencl-dev clinfo'
buildah run $container sh -c 'apt-get install -y jupyter-notebook'

buildah run $container sh -c 'update-alternatives --remove python /usr/bin/python2'
buildah run $container sh -c 'update-alternatives --install /usr/bin/python python /usr/bin/python3 10'

buildah run $container mkdir -p /etc/OpenCL/vendors
buildah run $container sh -c 'echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd'

[ $tag != "20.04" ] && buildah run $container sh -c 'rm /usr/bin/perf; ln -s /usr/lib/linux-tools/*/perf /usr/bin/perf'

buildah copy $container pre-setup /root/pre-setup
buildah run $container pip3 install -r /root/pre-setup/requirements.txt

buildah copy $container setup /root/setup
buildah commit --format docker $container pycuda:$tag