summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/note/qemu/build-gateleen.txt79
-rw-r--r--doc/note/qemu/qemu-networking.txt27
-rw-r--r--doc/note/qemu/qemu.txt36
-rw-r--r--src/main/docker/gateleen.Dockerfile65
4 files changed, 115 insertions, 92 deletions
diff --git a/doc/note/qemu/build-gateleen.txt b/doc/note/qemu/build-gateleen.txt
new file mode 100644
index 0000000..9666aa6
--- /dev/null
+++ b/doc/note/qemu/build-gateleen.txt
@@ -0,0 +1,79 @@
+
+
+### Alpine
+true \
+ && PKGS_TO_ADD="curl maven nodejs npm redis openjdk11-jre-headless" \
+ && SUDO="${HOME:?}/.local/bin/mysudo" \
+ && PKGINIT=true \
+ && PKGADD="$SUDO apk add" \
+ && PKGCLEAN=true \
+ && mkdir -p "${HOME:?}/.local/bin" \
+ && printf '%s\n' '#!/bin/sh' 'printf "Sudo "' 'su root -c "$(echo "$@")"' > "${HOME:?}/.local/bin/mysudo" \
+ && chmod u+x "${HOME:?}/.local/bin/mysudo" \
+ && true
+
+
+### Generic
+true \
+ && GATELEEN_GIT_TAG="v1.3.28" \
+ && WORKDIR="/${HOME:?}/work" \
+ && CACHE_DIR="/var/tmp" \
+ && true
+
+
+## Setup Dependencies & get sources
+true \
+ && ${PKGINIT:?} && ${PKGADD:?} $PKGS_TO_ADD \
+ \
+ && curl -sSL https://github.com/swisspush/gateleen/archive/refs/tags/"${GATELEEN_GIT_TAG:?}".tar.gz > "${CACHE_DIR:?}/gateleen-${GATELEEN_GIT_TAG:?}.tgz" \
+ && true
+
+
+### Make
+true \
+ && mkdir -p "${WORKDIR:?}/gateleen" && cd "${WORKDIR:?}/gateleen" \
+ && tar --strip-components 1 -xf "${CACHE_DIR:?}/gateleen-${GATELEEN_GIT_TAG:?}.tgz" \
+ && (cd gateleen-hook-js && npm install) \
+ && mkdir -p gateleen-hook-js/node/node_modules/npm/bin \
+ && ln -s /usr/bin/node gateleen-hook-js/node/node \
+ && printf "require('/usr/lib/node_modules/npm/lib/cli.js')\n" | tee gateleen-hook-js/node/node_modules/npm/bin/npm-cli.js >/dev/null \
+ && mvn install -PpublicRepos -DskipTests -Dskip.installnodenpm -pl gateleen-hook-js \
+ && mvn install -PpublicRepos -DfailIfNoTests=false \
+ -pl !gateleen-test,!gateleen-hook-js \
+ -Dtest=!ReleaseLockLuaScriptTests,!RedisCacheStorageTest,!DeltaHandlerTest,!QueueCircuitBreakerCloseCircuitLuaScriptTests,!QueueCircuitBreakerGetAllCircuitsLuaScriptTests,!QueueCircuitBreakerHalfOpenCircuitsLuaScriptTests,!QueueCircuitBreakerReOpenCircuitLuaScriptTests,!QueueCircuitBreakerUpdateStatsLuaScriptTests,!RemoveExpiredQueuesLuaScriptTests,!StartQueueTimerLuaScriptTests \
+ && mkdir "${WORKDIR:?}/classpath" \
+ && (cd gateleen-playground && mvn dependency:copy-dependencies \
+ -DexcludeScope=provided -DoutputDirectory="${WORKDIR:?}/classpath/.") \
+ && cp gateleen-playground/target/gateleen-playground-*.jar "${WORKDIR:?}/classpath/." \
+ && mkdir "${WORKDIR:?}/etc" "${WORKDIR:?}/redis-state" \
+ && printf >"${WORKDIR:?}/etc/redis.conf" '%s\n' \
+ 'save ""' \
+ 'appendonly yes' \
+ 'appendfilename appendonly.aof' \
+ && `# Squeeze those funny "static files" into redis` \
+ && (cd "${WORKDIR:?}/redis-state" && redis-server "${WORKDIR:?}/etc/redis.conf" \
+ & java -cp "${WORKDIR:?}/classpath/"'*' org.swisspush.gateleen.playground.Server \
+ & sleep 3 \
+ ) \
+ && (cd "${WORKDIR:?}/gateleen" && mvn deploy -PuploadStaticFiles) \
+ && (pkill -INT java || sleep 3 && pkill -TERM java || sleep 3 && pkill -9 java) \
+ && pkill -INT redis-server \
+ && $PKGDEL $PKGS_TO_DEL \
+ && $PKGCLEAN \
+ && sleep 3 \
+ && (cd "${WORKDIR:?}/gateleen" && mvn clean) \
+ && printf '\n DONE\n\n' \
+ && true
+
+
+### Run
+true \
+ && ip a | grep inet \
+ && (true \
+ && (cd "${WORKDIR:?}/redis-state" && redis-server "${WORKDIR:?}/etc/redis.conf") \
+ & true \
+ && cd ~ \
+ && java -cp "${WORKDIR:?}/classpath/"'*' org.swisspush.gateleen.playground.Server \
+ ) \
+ && true
+
diff --git a/doc/note/qemu/qemu-networking.txt b/doc/note/qemu/qemu-networking.txt
deleted file mode 100644
index 4318cb5..0000000
--- a/doc/note/qemu/qemu-networking.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-
-## Connect multiple VMs into one network
-
-TODO: All the (fu**) in here does NOT work, no matter how many RTFM
-tutorials I try.
-
-
-# launch one QEMU instance
-qemu-system-whatever \
- -device e1000,netdev=n1,mac=52:54:00:12:34:56 \
- -netdev socket,id=n1,mcast=230.0.0.1:1234 \
- ;
-# launch another QEMU instance on same "bus"
-qemu-system-whatever \
- -device e1000,netdev=n2,mac=52:54:00:12:34:57 \
- -netdev socket,id=n2,mcast=230.0.0.1:1234 \
- ;
-# launch yet another QEMU instance on same "bus"
-qemu-system-whatever \
- -device e1000,netdev=n3,mac=52:54:00:12:34:58 \
- -netdev socket,id=n3,mcast=230.0.0.1:1234 \
- ;
-
-## Sources
-
-- [connect VM networks](https://qemu.weilnetz.de/doc/6.0/system/invocation.html#sec-005finvocation)
-
diff --git a/doc/note/qemu/qemu.txt b/doc/note/qemu/qemu.txt
index b58b193..994527c 100644
--- a/doc/note/qemu/qemu.txt
+++ b/doc/note/qemu/qemu.txt
@@ -21,6 +21,8 @@ Qemu
### Convert raw to qcow2
qemu-img convert -f raw -O qcow2 foo.img foo.qcow2
+### Create Standalone image based on snapshot image
+ qemu-img convert -O qcow2 derived.qcow2 standalone.qcow2
## Shrink img
@@ -32,6 +34,39 @@ Windoof:
qemu-img convert -O qcow2 input.qcow output.qcow2
+## Example Params (Usage: CopyPaste, then delege what is not needed)
+qemu-system-x86_64 \
+ -enable-kvm -m size=4G -smp cores=$(nproc) \
+ -monitor stdio \
+ `# Drives & Boot.` \
+ -boot order=dc \
+ -cdrom "path/to/cd.iso" \
+ -hda "$(dirname "$(realpath "$0")")/hda.qcow2" \
+ `# 10.0.2.x network with host redirect` \
+ -netdev user,id=n0,hostfwd=tcp:127.0.0.1:${SSH_PORT:-2222}-:22 \
+ -device e1000,netdev=n0 \
+ `# socket mcast shared network adapter` \
+ -netdev socket,id=n1,mcast=230.0.0.1:1234 \
+ -device e1000,netdev=n1 \
+ `# Fix broken host systems` \
+ -L "${QEMU_HOME:?}/Bios" -bios "${QEMU_HOME:?}/Bios/bios-256k.bin" \
+ -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device usb-tablet \
+ `# Choose ONE of those for graphic output` \
+ -nographic \
+ -display gtk \
+ -display sdl \
+ ;
+
+### Example manual adapter setup (inside VM) for socket mcast network:
+true \
+ && ADDR=192.168.42.101/24 \
+ && DEV=ens4 \
+ && SUDO=sudo \
+ && $SUDO ip a add dev "${DEV:?}" "${ADDR:?}" \
+ && $SUDO ip link set "${DEV:?}" up \
+ && true
+
+
## amd64
# Choose whichever fits the need
@@ -217,4 +252,5 @@ TODO: move this to a better place. Eg: debian/setup.txt or whatever.
- [qemu monitor via telnet](https://unix.stackexchange.com/a/426951/292722)
- [qemu monitor via stdio](https://unix.stackexchange.com/a/57835/292722)
- [qemu raspberry pi TODO](https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/)
+- [connect VM networks](https://qemu.weilnetz.de/doc/6.0/system/invocation.html#sec-005finvocation)
diff --git a/src/main/docker/gateleen.Dockerfile b/src/main/docker/gateleen.Dockerfile
deleted file mode 100644
index f604dc2..0000000
--- a/src/main/docker/gateleen.Dockerfile
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# A Gateleen playground instance.
-#
-
-ARG PARENT_IMAGE=alpine:3.16.0
-FROM $PARENT_IMAGE
-
-ARG GATELEEN_GIT_TAG=v1.3.28
-ARG UID=1000
-ARG GID=1000
-ARG PKGS_TO_ADD="maven nodejs npm curl redis openjdk11-jre-headless"
-#ARG PKGS_TO_DEL="maven nodejs npm"
-ARG PKGS_TO_DEL="nodejs npm"
-ARG PKGINIT="true"
-ARG PKGADD="apk add"
-ARG PKGDEL="true"
-ARG PKGCLEAN="true"
-
-WORKDIR /work
-
-RUN true \
- && printf 'user:x:%s:%s:user:/work:/bin/sh\n' "${UID:?}" "${GID:?}" >> /etc/passwd \
- && true
-
-RUN true \
- && $PKGINIT && $PKGADD $PKGS_TO_ADD \
- && sed -i "s,</settings>, <localRepository>/data/maven/.m2/repository</localRepository>\n</settings>,g" /usr/share/java/maven-3/conf/settings.xml \
- && mkdir /data /data/maven /work/gateleen \
- && chown "${UID:?}:${GID:?}" /data/maven /work /work/gateleen \
- && curl -sSL https://github.com/swisspush/gateleen/archive/refs/tags/"$GATELEEN_GIT_TAG".tar.gz > "/tmp/gateleen-$GATELEEN_GIT_TAG.tgz" \
- && cd /work/gateleen \
- && su user -c 'tar --strip-components 1 -xf /tmp/gateleen-"$GATELEEN_GIT_TAG".tgz' \
- && (cd gateleen-hook-js && su user -c 'npm install') \
- && su user -c 'mkdir -p gateleen-hook-js/node/node_modules/npm/bin' \
- && su user -c 'ln -s /usr/bin/node gateleen-hook-js/node/node' \
- && printf "require('/usr/lib/node_modules/npm/lib/cli.js')\n" | su user -c 'tee gateleen-hook-js/node/node_modules/npm/bin/npm-cli.js' >/dev/null \
- && su user -c 'mvn install -PpublicRepos -DskipTests -Dskip.installnodenpm -pl gateleen-hook-js' \
- && su user -c 'mvn install -PpublicRepos -DfailIfNoTests=false \
- -pl !gateleen-test,!gateleen-hook-js \
- -Dtest=!ReleaseLockLuaScriptTests,!RedisCacheStorageTest,!DeltaHandlerTest,!QueueCircuitBreakerCloseCircuitLuaScriptTests,!QueueCircuitBreakerGetAllCircuitsLuaScriptTests,!QueueCircuitBreakerHalfOpenCircuitsLuaScriptTests,!QueueCircuitBreakerReOpenCircuitLuaScriptTests,!QueueCircuitBreakerUpdateStatsLuaScriptTests,!RemoveExpiredQueuesLuaScriptTests,!StartQueueTimerLuaScriptTests' \
- && mkdir /work/classpath \
- && chown "${UID:?}:${GID:?}" /work/classpath \
- && su user -c 'cd gateleen-playground && mvn dependency:copy-dependencies \
- -DexcludeScope=provided -DoutputDirectory=/work/classpath/.' \
- && cp gateleen-playground/target/gateleen-playground-*.jar /work/classpath/. \
- && mkdir /work/etc \
- && printf >/work/etc/redis.conf '%s\n' \
- 'save ""' \
- 'appendonly yes' \
- 'appenddirname "redis-state"' \
- 'appendfilename appendonly.aof' \
- && (su user -c 'cd /work && redis-server /work/etc/redis.conf & \
- java -cp '"'/work/classpath/*'"' org.swisspush.gateleen.playground.Server' \
- & sleep 3) \
- && su user -c 'cd /work/gateleen && mvn deploy -PuploadStaticFiles' \
- && pkill -INT java && pkill -INT redis-server \
- && $PKGDEL $PKGS_TO_DEL \
- && $PKGCLEAN \
- && true
-
-USER "${UID}:${GID}"
-
-#CMD ["sleep", "36000"]
-CMD ["sh", "-c", "ip a|grep inet && redis-server /work/etc/redis.conf & java -cp '/work/classpath/*' org.swisspush.gateleen.playground.Server"]
-