From 28a24c471be723dcc407452cac77ace4ec46f722 Mon Sep 17 00:00:00 2001 From: Karina Antoniu Date: Sat, 9 May 2026 09:38:51 +0000 Subject: [PATCH 1/2] bincompat-nginx: Configure NGINX with elfloader Add Makefile and setup.sh to configure NGINX via elfloader. Include Dockerfile and Makefile in rootfs/ to automate the extraction of the NGINX binary and its shared libraries. Signed-off-by: Karina Antoniu --- bincompat-nginx/.gitignore | 2 ++ bincompat-nginx/Makefile | 13 ++++++++++ bincompat-nginx/rootfs/Dockerfile | 12 +++++++++ bincompat-nginx/rootfs/Makefile | 14 +++++++++++ bincompat-nginx/setup.sh | 41 +++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 bincompat-nginx/.gitignore create mode 100644 bincompat-nginx/Makefile create mode 100644 bincompat-nginx/rootfs/Dockerfile create mode 100644 bincompat-nginx/rootfs/Makefile create mode 100755 bincompat-nginx/setup.sh diff --git a/bincompat-nginx/.gitignore b/bincompat-nginx/.gitignore new file mode 100644 index 00000000..902b58e3 --- /dev/null +++ b/bincompat-nginx/.gitignore @@ -0,0 +1,2 @@ +workdir/ +rootfs/extracted_rootfs/ diff --git a/bincompat-nginx/Makefile b/bincompat-nginx/Makefile new file mode 100644 index 00000000..ca979572 --- /dev/null +++ b/bincompat-nginx/Makefile @@ -0,0 +1,13 @@ +UK_ROOT ?= $(PWD)/workdir/unikraft +UK_BUILD ?= $(PWD)/workdir/build +UK_APP ?= $(PWD)/workdir/apps/elfloader +LIBS_BASE = $(PWD)/workdir/libs +UK_LIBS ?= $(LIBS_BASE)/musl:$(LIBS_BASE)/lwip:$(LIBS_BASE)/libelf:$(PWD)/workdir/libs/zlib + +.PHONY: all + +all: + @$(MAKE) -C $(UK_ROOT) L=$(UK_LIBS) A=$(UK_APP) O=$(UK_BUILD) + +$(MAKECMDGOALS): + @$(MAKE) -C $(UK_ROOT) L=$(UK_LIBS) A=$(UK_APP) O=$(UK_BUILD) $(MAKECMDGOALS) diff --git a/bincompat-nginx/rootfs/Dockerfile b/bincompat-nginx/rootfs/Dockerfile new file mode 100644 index 00000000..50947404 --- /dev/null +++ b/bincompat-nginx/rootfs/Dockerfile @@ -0,0 +1,12 @@ +FROM nginx:1.25 + +RUN mkdir -p /rootfs/usr/sbin /rootfs/etc/nginx /rootfs/usr/share/nginx/html /rootfs/var/log/nginx /rootfs/var/run /rootfs/tmp /rootfs/lib + +RUN cp /usr/sbin/nginx /rootfs/usr/sbin/ +RUN cp -r /etc/nginx/* /rootfs/etc/nginx/ +RUN cp -r /usr/share/nginx/html/* /rootfs/usr/share/nginx/html/ + + +RUN echo "daemon off;" >> /rootfs/etc/nginx/nginx.conf + +RUN ldd /usr/sbin/nginx | grep -o '/lib/[^ ]*' | xargs -I {} cp {} /rootfs/lib/ diff --git a/bincompat-nginx/rootfs/Makefile b/bincompat-nginx/rootfs/Makefile new file mode 100644 index 00000000..baeade21 --- /dev/null +++ b/bincompat-nginx/rootfs/Makefile @@ -0,0 +1,14 @@ +ROOTFS_DIR := ./extracted_rootfs +DOCKER_IMAGE := nginx-catalog-core-rootfs + +.PHONY: all clean + +all: + docker build -t $(DOCKER_IMAGE) . + docker create --name temp-container $(DOCKER_IMAGE) + docker cp temp-container:/rootfs $(ROOTFS_DIR) + docker rm temp-container + docker rmi $(DOCKER_IMAGE) + +clean: + rm -rf $(ROOTFS_DIR) diff --git a/bincompat-nginx/setup.sh b/bincompat-nginx/setup.sh new file mode 100755 index 00000000..3a7956d8 --- /dev/null +++ b/bincompat-nginx/setup.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +check_exists_and_create_symlink() +{ + path="$1" + + if ! test -d workdir/"$path"; then + if ! test -d ../repos/"$path"; then + echo "No directory ../repos/$path. Run the top-level setup.sh script first." 1>&2 + exit 1 + fi + depth=$(echo "$path" | awk -F / '{ print NF }') + if test "$depth" -eq 1; then + ln -sfn ../../repos/"$path" workdir/"$path" + elif test "$depth" -eq 2; then + ln -sfn ../../../repos/"$path" workdir/"$path" + else + echo "Unknown depth of path $path." 1>&2 + exit 1 + fi + fi +} + +if ! test -d workdir; then + mkdir workdir +fi + +if ! test -d workdir/libs; then + mkdir workdir/libs +fi + +if ! test -d workdir/apps; then + mkdir workdir/apps +fi + +check_exists_and_create_symlink "unikraft" +check_exists_and_create_symlink "libs/musl" +check_exists_and_create_symlink "libs/lwip" +check_exists_and_create_symlink "apps/elfloader" +check_exists_and_create_symlink "libs/libelf" +check_exists_and_create_symlink "libs/zlib" \ No newline at end of file From bb6358e7c1e866dfdaa1a5490b9a541dbd954dd0 Mon Sep 17 00:00:00 2001 From: Karina Antoniu Date: Mon, 11 May 2026 09:36:49 +0000 Subject: [PATCH 2/2] bincompat-nginx: Refactor setup - Remove local Makefile and setup.sh - Update Dockerfile and rootfs Makefile Signed-off-by: Karina Antoniu --- bincompat-nginx/Makefile | 13 ---------- bincompat-nginx/rootfs/Dockerfile | 1 - bincompat-nginx/rootfs/Makefile | 1 - bincompat-nginx/setup.sh | 41 ------------------------------- 4 files changed, 56 deletions(-) delete mode 100644 bincompat-nginx/Makefile delete mode 100755 bincompat-nginx/setup.sh diff --git a/bincompat-nginx/Makefile b/bincompat-nginx/Makefile deleted file mode 100644 index ca979572..00000000 --- a/bincompat-nginx/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -UK_ROOT ?= $(PWD)/workdir/unikraft -UK_BUILD ?= $(PWD)/workdir/build -UK_APP ?= $(PWD)/workdir/apps/elfloader -LIBS_BASE = $(PWD)/workdir/libs -UK_LIBS ?= $(LIBS_BASE)/musl:$(LIBS_BASE)/lwip:$(LIBS_BASE)/libelf:$(PWD)/workdir/libs/zlib - -.PHONY: all - -all: - @$(MAKE) -C $(UK_ROOT) L=$(UK_LIBS) A=$(UK_APP) O=$(UK_BUILD) - -$(MAKECMDGOALS): - @$(MAKE) -C $(UK_ROOT) L=$(UK_LIBS) A=$(UK_APP) O=$(UK_BUILD) $(MAKECMDGOALS) diff --git a/bincompat-nginx/rootfs/Dockerfile b/bincompat-nginx/rootfs/Dockerfile index 50947404..14af0e1c 100644 --- a/bincompat-nginx/rootfs/Dockerfile +++ b/bincompat-nginx/rootfs/Dockerfile @@ -6,7 +6,6 @@ RUN cp /usr/sbin/nginx /rootfs/usr/sbin/ RUN cp -r /etc/nginx/* /rootfs/etc/nginx/ RUN cp -r /usr/share/nginx/html/* /rootfs/usr/share/nginx/html/ - RUN echo "daemon off;" >> /rootfs/etc/nginx/nginx.conf RUN ldd /usr/sbin/nginx | grep -o '/lib/[^ ]*' | xargs -I {} cp {} /rootfs/lib/ diff --git a/bincompat-nginx/rootfs/Makefile b/bincompat-nginx/rootfs/Makefile index baeade21..8d69f7ba 100644 --- a/bincompat-nginx/rootfs/Makefile +++ b/bincompat-nginx/rootfs/Makefile @@ -8,7 +8,6 @@ all: docker create --name temp-container $(DOCKER_IMAGE) docker cp temp-container:/rootfs $(ROOTFS_DIR) docker rm temp-container - docker rmi $(DOCKER_IMAGE) clean: rm -rf $(ROOTFS_DIR) diff --git a/bincompat-nginx/setup.sh b/bincompat-nginx/setup.sh deleted file mode 100755 index 3a7956d8..00000000 --- a/bincompat-nginx/setup.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -check_exists_and_create_symlink() -{ - path="$1" - - if ! test -d workdir/"$path"; then - if ! test -d ../repos/"$path"; then - echo "No directory ../repos/$path. Run the top-level setup.sh script first." 1>&2 - exit 1 - fi - depth=$(echo "$path" | awk -F / '{ print NF }') - if test "$depth" -eq 1; then - ln -sfn ../../repos/"$path" workdir/"$path" - elif test "$depth" -eq 2; then - ln -sfn ../../../repos/"$path" workdir/"$path" - else - echo "Unknown depth of path $path." 1>&2 - exit 1 - fi - fi -} - -if ! test -d workdir; then - mkdir workdir -fi - -if ! test -d workdir/libs; then - mkdir workdir/libs -fi - -if ! test -d workdir/apps; then - mkdir workdir/apps -fi - -check_exists_and_create_symlink "unikraft" -check_exists_and_create_symlink "libs/musl" -check_exists_and_create_symlink "libs/lwip" -check_exists_and_create_symlink "apps/elfloader" -check_exists_and_create_symlink "libs/libelf" -check_exists_and_create_symlink "libs/zlib" \ No newline at end of file