Skip to content

Commit 5d712d7

Browse files
committed
chore: add config for docker support security nesting inside the lxd container, and install deps inside the container
1 parent a94a68f commit 5d712d7

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

scripts/test_install.sh

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,61 @@ function get_lxd_container_name() {
137137
}
138138

139139

140-
# Create a new lxd container for a specific distribution
141-
function create_lxd_container() {
140+
# Create a new LXD container with Docker privileges
141+
create_lxd_container() {
142142
local distro="$1"
143143
CONTAINER_NAME=$(get_lxd_container_name "$distro")
144-
144+
145145
echo "Creating container: $CONTAINER_NAME with image: $distro"
146146
sudo lxc launch images:"$distro" "$CONTAINER_NAME"
147-
148-
# Wait for container to be ready
147+
sudo lxc config set "$CONTAINER_NAME" security.privileged true
148+
sudo lxc config set "$CONTAINER_NAME" security.nesting true
149+
sudo lxc restart "$CONTAINER_NAME"
149150
echo "Waiting for container to be ready..."
151+
sleep 10
150152
sudo lxc exec "$CONTAINER_NAME" -- cloud-init status --wait 2>/dev/null || true
151153
}
152154

155+
# Install dependencies in the container
156+
function install_dependencies_in_container() {
157+
local container_name="$1"
158+
local distro="$2"
159+
echo "Installing dependencies in container: $container_name"
160+
# Install the dependencies based on the distro
161+
case $distro in
162+
"alpine")
163+
echo "Installing dependencies for Alpine"
164+
sudo lxc exec "$container_name" -- apk add --no-cache python3 docker py3-pip git openssl
165+
;;
166+
"fedora")
167+
echo "Installing dependencies for Fedora"
168+
sudo lxc exec "$container_name" -- dnf install -y python3 docker python3-pip git openssl
169+
;;
170+
"debian")
171+
echo "Installing dependencies for Debian"
172+
sudo lxc exec "$container_name" -- apt-get update
173+
sudo lxc exec "$container_name" -- apt-get install -y python3 docker python3-pip git openssl
174+
;;
175+
"archlinux")
176+
echo "Installing dependencies for Arch Linux"
177+
sudo lxc exec "$container_name" -- pacman -Sy --noconfirm python3 docker python3-pip git openssl
178+
;;
179+
"centos")
180+
echo "Installing dependencies for CentOS"
181+
sudo lxc exec "$container_name" -- yum install -y python3 docker python3-pip git openssl
182+
;;
183+
"gentoo")
184+
echo "Installing dependencies for Gentoo"
185+
sudo lxc exec "$container_name" -- emerge --ask nix python3 docker python3-pip git openssl
186+
;;
187+
"ubuntu")
188+
echo "Installing dependencies for Ubuntu"
189+
sudo lxc exec "$container_name" -- apt-get update
190+
sudo lxc exec "$container_name" -- apt-get install -y python3 docker python3-pip git openssl
191+
;;
192+
esac
193+
}
194+
153195
# Build installation command
154196
function build_installation_command() {
155197
local email="$1"
@@ -231,6 +273,8 @@ function test_distribution_with_params() {
231273
return 0
232274
fi
233275

276+
install_dependencies_in_container "$CONTAINER_NAME" "$distro"
277+
234278
if run_installation_script "$(build_installation_command "$email" "$password" "$api_domain" "$app_domain" "$env")"; then
235279
test_result="PASSED"
236280
else

0 commit comments

Comments
 (0)