Changeset

13323:7bfd6db52528

tools/build-env: Tools for building and testing in a container ./tools/build-env/build.sh Creates a container image based on Debian or Ubuntu ./tools/build-env/here.sh Starts a container and mounts in the current working directory, from where one can ./configure; make; make test etc
author Kim Alvefur <zash@zash.se>
date Sun, 12 Nov 2023 13:02:38 +0100
parents 13322:28211ed70b4c
children 13324:6f371066d6e0
files tools/build-env/Containerfile tools/build-env/build.sh tools/build-env/here.sh
diffstat 3 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/build-env/Containerfile	Sun Nov 12 13:02:38 2023 +0100
@@ -0,0 +1,31 @@
+ARG os
+ARG dist
+FROM ${os:-debian}:${dist:-sid}
+ENV DEBIAN_FRONTEND noninteractive
+RUN set -ex; \
+	apt-get update; \
+	apt-get install -y --no-install-recommends \
+	ccache dh-lua libicu-dev libidn11-dev libssl-dev \
+	lua-bitop lua-dbi-mysql lua-dbi-postgresql lua-dbi-sqlite3 \
+	lua-event lua-expat lua-filesystem lua-ldap lua-sec lua-socket \
+	luarocks shellcheck mercurial; \
+	apt-get install -y ca-certificates dns-root-data; \
+	apt-get install -y lua-bit32 || true; \
+	apt-get install -y lua-busted || true; \
+	apt-get install -y lua-check || true; \
+	apt-get install -y lua-readline || true; \
+	apt-get install -y lua-unbound || true; \
+	update-alternatives --set lua-interpreter /usr/bin/lua5.4 || true \
+	apt-get clean
+
+# Place this file in an empty directory and build the image with
+# podman build . -t prosody.im/build-env
+#
+# Substituting podman for docker should work, where that is what's available.
+#
+# Then in a source directory, run:
+# podman run -it --rm -v "$PWD:$PWD" -w "$PWD" --entrypoint /bin/bash \
+#            --userns=keep-id --network host prosody.im/build-env
+#
+# In the resulting environment everything required to compile and run prosody
+# is available, so e.g. `./configure; make; ./prosody` should Just Work!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/build-env/build.sh	Sun Nov 12 13:02:38 2023 +0100
@@ -0,0 +1,11 @@
+#!/bin/sh -eux
+
+cd "$(dirname "$0")"
+
+containerify="$(command -v podman docker)"
+
+$containerify build -f ./Containerfile --squash \
+	--build-arg os="${2:-debian}" \
+	--build-arg dist="${1:-testing}" \
+	-t "prosody.im/build-env:${1:-testing}"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/build-env/here.sh	Sun Nov 12 13:02:38 2023 +0100
@@ -0,0 +1,19 @@
+#!/bin/sh -eux
+
+tag="testing"
+
+if [ "$#" -gt 0 ]; then
+	tag="$1"
+	shift
+fi
+
+containerify="$(command -v podman docker)"
+
+$containerify run -it --rm \
+	-v "$PWD:$PWD" \
+	-w "$PWD" \
+	-v "$HOME/.cache:$PWD/.cache" \
+	--entrypoint /bin/bash \
+	--userns=keep-id \
+	--network \
+	host "prosody.im/build-env:$tag" "$@"