I am trying to build the following apptainer. the last part of the script compiles the octopus variant caller.
Bootstrap: docker
From: ubuntu:latest
%environment
DEBIAN_FRONTEND=noninteractive
TZ=Europe/London
PATH=/opt/octopus/bin:${PATH}
%files
./octopus /opt/octopus
%post
apt-get -y update
apt-get -y install software-properties-common
apt-get install -y --no-install-recommends apt-utils
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get -y install gcc g++ build-essential git curl python3-pip
# pip3 install distro
apt install python3-distro -y
mkdir -p /opt/octopus
# compile octopus
/opt/octopus/scripts/install.py --dependencies --forests --threads 4
%runscript
exec octopus "$@"
If I understand correctly the %post part of the apptainer.def is run as a root user. This causes problems later in the compilation which requires brew. Running the script as root seems to be the cause of the following error during build
Cloning into 'brew'...
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
No bin directory found, making one
Traceback (most recent call last):
File "/opt/octopus/scripts/install.py", line 511, in <module>
main(args)
File "/opt/octopus/scripts/install.py", line 355, in main
dependencies_dir, dependencies_binaries = install_dependencies(octopus_build_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/octopus/scripts/install.py", line 292, in install_dependencies
brew_bin = install_homebrew(build_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/octopus/scripts/install.py", line 232, in install_homebrew
init_homebrew(brew_bin_dir)
File "/opt/octopus/scripts/install.py", line 210, in init_homebrew
if is_old_brew_config_curl(brew_bin):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/octopus/scripts/install.py", line 120, in is_old_brew_config_curl
brew_config = check_output([str(brew_bin), 'config']).decode("utf-8").split()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/opt/octopus/build/brew/bin/brew', 'config']' returned non-zero exit status 1.
FATAL: While performing build: while running engine: exit status 1
My question is, is it possible tell brew it is fime to run as root (I can’t do much damage during a container build) or to run the %post scriptlet as a non-root user. This might cause problems in the compilation, though, I am not sure.