Repository navigation
Expand file tree
/
Copy pathVagrantfile
More file actions
141 lines (115 loc) · 3.88 KB
/
Copy pathVagrantfile
File metadata and controls
141 lines (115 loc) · 3.88 KB
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
# Ubuntu 24.04 LTS development VM
# macOS Intel + VirtualBox 7.2 + Vagrant 2.4
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-24.04"
config.vm.box_architecture = "amd64"
config.vm.hostname = "ubuntu-dev"
# SSH forwarding managed automatically by Vagrant
config.vm.usable_port_range = (2200..2999)
# --------------------------------------------------
# Shared folder: macOS project directory -> Ubuntu
# --------------------------------------------------
config.vm.synced_folder ".", "/vagrant",
type: "virtualbox",
create: true
# Dynamically allocated disk, maximum 100 GB
config.vm.disk :disk, size: "100GB", primary: true
# --------------------------------------------------
# VirtualBox configuration
# --------------------------------------------------
config.vm.provider "virtualbox" do |vb|
vb.name = "ubuntu-dev"
vb.memory = 8192
vb.cpus = 2
vb.gui = false
end
# --------------------------------------------------
# System provisioning
# --------------------------------------------------
config.vm.provision "shell", inline: <<-'SHELL'
set -eux
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y \
ca-certificates \
curl \
git \
bzip2 \
vim \
byobu \
fish \
software-properties-common \
python3 \
python3-pip \
python3-venv \
pipx \
podman \
uidmap \
slirp4netns \
fuse-overlayfs
# ------------------------------------------------
# VirtualBox Guest Additions
# ------------------------------------------------
apt-get install -y \
virtualbox-guest-utils \
virtualbox-guest-dkms
# Allow vagrant user to access shared folders
usermod -aG vboxsf vagrant
# ------------------------------------------------
# Miniforge
# ------------------------------------------------
if [ ! -x /opt/conda/bin/conda ]; then
curl -fsSL \
https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh \
-o /tmp/miniforge.sh
bash /tmp/miniforge.sh -b -p /opt/conda
rm -f /tmp/miniforge.sh
fi
# Make conda available in login shells
cat > /etc/profile.d/miniforge.sh <<'EOF'
export PATH="/opt/conda/bin:$PATH"
EOF
# Conda configuration
/opt/conda/bin/conda config --system \
--set channel_priority strict
/opt/conda/bin/conda config --system \
--set auto_activate_base false
/opt/conda/bin/conda config --system \
--set show_channel_urls true
# Allow vagrant user to manage environments
chown -R vagrant:vagrant /opt/conda
# Enable conda in interactive Bash sessions
grep -qxF \
'source /opt/conda/etc/profile.d/conda.sh' \
/home/vagrant/.bashrc || \
echo 'source /opt/conda/etc/profile.d/conda.sh' \
>> /home/vagrant/.bashrc
# ------------------------------------------------
# Podman and podman-compose
# ------------------------------------------------
loginctl enable-linger vagrant
runuser -u vagrant -- \
env HOME=/home/vagrant \
pipx install podman-compose || true
# Add pipx applications to PATH
grep -qxF \
'export PATH="$HOME/.local/bin:$PATH"' \
/home/vagrant/.bashrc || \
echo 'export PATH="$HOME/.local/bin:$PATH"' \
>> /home/vagrant/.bashrc
# ------------------------------------------------
# Fish shell
# ------------------------------------------------
grep -qxF /usr/bin/fish /etc/shells || \
echo /usr/bin/fish >> /etc/shells
# Byobu installed, but not started automatically
# ------------------------------------------------
# Verification
# ------------------------------------------------
/opt/conda/bin/conda --version
podman --version
git --version
python3 --version
fish --version
SHELL
end