-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.def
204 lines (175 loc) · 7.03 KB
/
image.def
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
Bootstrap: docker
From: nvidia/cuda:12.6.2-base-ubuntu22.04
%environment
# Set environment variables accessible within the container
export USERNAME=${USER:-$(id -un)}
export INTERNAL_DIR=/home/
export SINIMAGE_DIR=/mnt/local/$USERNAME/sinimage/home
export CONDA_PKGS_DIRS=$SINIMAGE_DIR/conda/pkgs
export CONDA_ENVS_DIRS=$SINIMAGE_DIR/conda/envs
export CONDA_CACHE_DIR=$SINIMAGE_DIR/.local/cache/conda
export CONDA_PREFIX=/opt/conda
export PYTHONUSERBASE=$SINIMAGE_DIR/.local
export JUPYTER_RUNTIME_DIR=$SINIMAGE_DIR/.local/share/jupyter/runtime
export IPYTHONDIR=$SINIMAGE_DIR/.local/share/ipython
export JUPYTER_CONFIG_DIR=$SINIMAGE_DIR/.local/etc/jupyter
export JUPYTER_DATA_DIR=$SINIMAGE_DIR/.local/share/jupyter
export MPLCONFIGDIR=$SINIMAGE_DIR/.local/share/matplotlib
export XDG_CONFIG_HOME=$SINIMAGE_DIR/.local/etc
export XDG_DATA_HOME=$SINIMAGE_DIR/.local/share
export XDG_CACHE_HOME=$SINIMAGE_DIR/.local/cache
export CODE_SERVER_CONFIG=$SINIMAGE_DIR/.local/etc/code-server/config.yaml
export JUPYTER_IP=0.0.0.0
export PATH=/opt/conda/bin:$SINIMAGE_DIR/.local/bin:$PATH
export CONDA_NO_PLUGIN=True
export NVM_DIR=/opt/.nvm
export CODE_SERVER_CONFIG="/opt/code-server/config/config.yaml"
export SHELL=/opt/conda/bin/zsh
export XDG_STATE_HOME=$SINIMAGE_DIR/.local/state
export CUDA_CACHE_PATH=$SINIMAGE_DIR/.cache/nv
export TMPDIR=$SINIMAGE_DIR/.local/tmp
export mumax_port=35999
export code_port=8090
export SCREENDIR=$SINIMAGE_DIR/tmp
export ZELLIJ_TMP_DIR=$HOME/.zellij
export RUST_BACKTRACE=1
%files
# Copy configuration files to container
./starship.toml /opt/temp_files/starship.toml
./.zshrc /opt/temp_files/.zshrc
./code-server/config.yaml /opt/code-server/config/config.yaml
./code-server/extensions-list.txt /opt/temp_files/extensions-list.txt
%post
# ===========================
# 1. Install System Packages
# ===========================
apt-get update && apt-get install -y \
curl \
ca-certificates \
git \
bzip2 \
libx11-6 \
gcc \
llvm \
cmake \
libfftw3-dev \
exa \
nano \
rclone \
make \
g++ \
libsndfile1 \
screen \
tmux \
autossh \
wget
# ===========================
# 2. Install Miniconda
# ===========================
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh
# Add conda to PATH
export PATH="/opt/conda/bin:$PATH"
# Configure conda channels
conda config --file /.condarc --add channels defaults
conda config --file /.condarc --add channels conda-forge
# Update conda and install essential Python packages
conda update -y conda
conda install -y python=3.12 pip
# Clean up unused packages to reduce image size
conda clean --all -y
# ===========================
# 3. Install Amumax and Mumax
# ===========================
sh -c "$(curl -fsSL https://raw.githubusercontent.com/MathieuMoalic/amumax/main/install.sh)" -- /opt/conda/bin/
# Download and install Mumax3
MUMAX_VERSION="mumax3.10_linux_cuda11.0"
MUMAX_URL="https://mumax.ugent.be/mumax3-binaries/${MUMAX_VERSION}.tar.gz"
MUMAX_INSTALL_DIR="/opt/conda/bin/mumax3"
# Create installation directory in /opt/conda/bin
mkdir -p $MUMAX_INSTALL_DIR
# Download and extract Mumax3 directly into /opt/conda/bin
curl -L $MUMAX_URL | tar -xz -C /opt/conda/bin --strip-components=1
# Ensure mumax3 binary is accessible
chmod +x /opt/conda/bin/mumax3
# ===========================
# 4. Install Additional Conda Packages
# ===========================
conda install -y conda-forge::zsh # ZSH shell
ln -s /opt/conda/bin/zsh /bin/zsh
conda install -y -c conda-forge zoxide # Directory navigation
conda install -y conda-forge::bat # Enhanced 'cat' command
conda install -y conda-forge::starship # Starship prompt
conda install -y conda-forge::atuin
conda install -y dnachun::btop
conda install conda-forge::zellij
# ===========================
# 5. Install NVM and Node.js
# ===========================
# Set up NVM environment
export NVM_DIR="/opt/.nvm"
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
. "$NVM_DIR/nvm.sh"
# Load NVM scripts for persistent availability
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # Loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # Loads nvm bash_completion
# Install and set up Node.js version 20
nvm install 20
nvm use 20
nvm alias default 20
# ===========================
# 6. Install Code Server
# ===========================
mkdir -p /opt/code/
export VSCODE_EXTENSIONS=/opt/code/
curl -fOL https://github.com/coder/code-server/releases/download/v4.95.1/code-server_4.95.1_amd64.deb
dpkg -i code-server_4.95.1_amd64.deb
# Install each extension listed in `extensions-list.txt`
EXTENSIONS_LIST=/opt/temp_files/extensions-list.txt
while IFS= read -r extension; do
echo "Installing extension: $extension"
code-server --install-extension "$extension" --force
done < "$EXTENSIONS_LIST"
cp -r /root/.config/code-server /opt/code-server-settings
cp -r /root/.local/share/code-server /opt/code-server-settings
chmod -R 755 /opt/code-server-settings
# ===========================
# 7. Install Python Packages with pip
# ===========================
pip install pyzfn \
uv \
rust \
pydantic \
mypy \
scipy \
cmcrameri \
seaborn \
pandas
# ===========================
# 8. Install JupyterLab and Build
# ===========================
conda install -y -c conda-forge jupyterlab
jupyter-lab build
%runscript
# Move configuration files to a new home directory if they don't exist there
if [ ! -f "$SINIMAGE_DIR/home/.zshrc" ]; then
cp /opt/temp_files/.zshrc "$SINIMAGE_DIR/.zshrc"
mkdir $SCREENDIR
chmod 700 $SCREENDIR
mkdir -p $HOME/.zellij
chmod 700 $HOME/.zellij
fi
if [ ! -f "$SINIMAGE_DIR/home/.config/starship.toml" ]; then
cp /opt/temp_files/starship.toml "$SINIMAGE_DIR/.config/starship.toml"
chmod 644 $SINIMAGE_DIR/.config/starship.toml
fi
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # Load nvm bash_completion
. /opt/conda/etc/profile.d/conda.sh
if [ ! -d "$HOME/.local/share/code-server" ]; then
rclone copy /opt/code-server-settings/code-server "$HOME/.local/share/code-server"
fi
exec zsh