From 4c7551d9f69f2c0d3122c9875a25188142618d5f Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 22 Dec 2024 23:13:56 -0500 Subject: [PATCH 1/5] update submodules --- mocha-common | 2 +- mocha-php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mocha-common b/mocha-common index 54d5ab8..569e302 160000 --- a/mocha-common +++ b/mocha-common @@ -1 +1 @@ -Subproject commit 54d5ab8b2c37bb9139eb6800631eece9b60ee25a +Subproject commit 569e302f3000e236ba562f17bc83d9e70a54fbf5 diff --git a/mocha-php b/mocha-php index 2a964d1..4312da2 160000 --- a/mocha-php +++ b/mocha-php @@ -1 +1 @@ -Subproject commit 2a964d1b5c0db71d731edfd3e442dc5d7f952786 +Subproject commit 4312da2f0023df7047173111c85281a563d4c13d From a81a816d2ebf52975dbd27eaf345e1ca66d97769 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 22 Dec 2024 23:15:03 -0500 Subject: [PATCH 2/5] add package installation for mocha-suv/cup --- mocha-suv/configure | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mocha-suv/configure b/mocha-suv/configure index c17f24f..a4dc359 100644 --- a/mocha-suv/configure +++ b/mocha-suv/configure @@ -1,6 +1,21 @@ # mocha-suv post-installation configuration script # to be run on the SUV virtual machine (if building manually) +# set to 0 if we already have an installed SUV or CUP +FULL=1 + +if [ $FULL -eq 1 ]; then + # update the package repository and install required packages + apt update + # !!! NOTE: we are no longer requiring mysql for Mocha if we use the mocha-dotnet OMS + apt install apache2 php pwgen + + apt install dotnet-runtime-8.0 + + mkdir -p /usr/share/mocha/system + +fi + ENABLE_SSL=1 if [ $ENABLE_SSL -eq 1 ]; then From 5cb9126e7f9f2956e5d61c4f186fb935a98fa5c7 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 23 Dec 2024 00:44:57 -0500 Subject: [PATCH 3/5] support multiple backends; e.g. lxc --- mocha-suv/provision | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mocha-suv/provision b/mocha-suv/provision index cdebc1f..ca5d739 100755 --- a/mocha-suv/provision +++ b/mocha-suv/provision @@ -16,7 +16,13 @@ SUV_IP=$SUV_IP_PREFIX.$SUV_IP_FIRST.$SUV_IP_LAST SUV_ALWAYS_PROVISION="false" SUV_UNATTENDED="false" -USE_VAGRANT="false" +BACKEND="virtualbox" + +if [ "$1" == "--backend" ]; then + BACKEND="$2" + shift + shift +fi if [ "$1" == "--transient" ]; then shift @@ -32,10 +38,6 @@ if [ "$1" == "--unattended" ]; then shift fi -if [ "$1" == "--use-vagrant" ]; then - USE_VAGRANT="true" -fi - SUV_TEMPLATE="default" if [ "$1" != "" ]; then @@ -90,11 +92,11 @@ fi sed -i -e "s/@@MOCHA_SUV_ID@@/$SUV_NAME/" -e "s/@@MOCHA_SUV_ADDRESS@@/$SUV_IP/" -e "s/@@MOCHA_SUV_HOSTNAME@@/$SUV_IP_OR_DNS/" -e "s/@@MOCHA_ALWAYS_PROVISION@@/$SUV_ALWAYS_PROVISION/" ./Vagrantfile -if [ "$USE_VAGRANT" == "true" ]; then +if [ "$BACKEND" == "vagrant" ]; then vagrant up -else +elif [ "$BACKEND" == "virtualbox" ]; then # create a new Host-Only Network Interface HOIFNAME=$(VBoxManage hostonlyif create | grep -o -P "(?<=').*(?=')" ) @@ -107,6 +109,10 @@ else # assign the newly-created Host-Only Network Interface to the newly-created VM VBoxManage modifyvm mochasuv-$SUV_NAME --nic2=hostonly --host-only-adapter2=$HOIFNAME +else + + echo "backend not supported: $BACKEND" + fi if [ "$?" != "0" ]; then From 07bb5516c10eef845e6839390bd399974668ffc4 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 23 Dec 2024 00:45:22 -0500 Subject: [PATCH 4/5] update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e7f20f0..02eab18 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ # Provisioned SUVs machines/ +*.swp + From ccfea09e3f7e047fe7a564ccf6449b278d5e7561 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 23 Dec 2024 00:46:02 -0500 Subject: [PATCH 5/5] preliminary support for cross-platform docker containers --- docker-build | 17 +++++++++++++++++ mocha-suv/docker/Dockerfile | 7 +++++++ 2 files changed, 24 insertions(+) create mode 100755 docker-build create mode 100644 mocha-suv/docker/Dockerfile diff --git a/docker-build b/docker-build new file mode 100755 index 0000000..76bcc14 --- /dev/null +++ b/docker-build @@ -0,0 +1,17 @@ +#!/bin/bash + +# generate random UUID for new SUV +# thanks https://stackoverflow.com/questions/34328759 +SUV_ID=$(hexdump -vn8 -e'2/4 "%08x" 1 "\n"' /dev/urandom) +SUV_NAME=i-0$SUV_ID + +# build the image (i.e. 'mocha suv init' ) +docker build -t mocha-httpd -f mocha-suv/docker/Dockerfile . + +# initiate a container (i.e. 'mocha suv up i-0...' ) +docker run --name $SUV_NAME -d --net mocha-docker -it mocha-httpd # -p 8000:80 mocha-httpd + +echo "waiting for network to settle..." +sleep 3 + +docker inspect $SUV_NAME diff --git a/mocha-suv/docker/Dockerfile b/mocha-suv/docker/Dockerfile new file mode 100644 index 0000000..e3193cb --- /dev/null +++ b/mocha-suv/docker/Dockerfile @@ -0,0 +1,7 @@ +FROM httpd + +RUN apt update && apt upgrade && apt install -y php php-mbstring php-curl php-xml pwgen +RUN rm /usr/local/apache2/htdocs/index.html + +COPY mocha-php/mocha-php/src/mocha-php /usr/local/apache2/htdocs/ +