From 4236cf05b8cc609d0fc020fce1ef6f8427c0aa8d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 31 Oct 2016 10:52:44 +0000 Subject: [PATCH] draft of h2o package support --- h2o/Makefile | 45 ++++++++++++++++++++++++++++++++++ h2o/README.md | 38 ++++++++++++++++++++++++++++ h2o/h2o.conf | 9 +++++++ h2o/images/data/conf/h2o.conf | 7 ++++++ h2o/images/data/www/index.html | 10 ++++++++ h2o/patches/CMakeLists.diff | 11 +++++++++ 6 files changed, 120 insertions(+) create mode 100644 h2o/Makefile create mode 100644 h2o/README.md create mode 100644 h2o/h2o.conf create mode 100644 h2o/images/data/conf/h2o.conf create mode 100644 h2o/images/data/www/index.html create mode 100644 h2o/patches/CMakeLists.diff diff --git a/h2o/Makefile b/h2o/Makefile new file mode 100644 index 00000000..43abc6dc --- /dev/null +++ b/h2o/Makefile @@ -0,0 +1,45 @@ +include ../Makefile.inc +UPSTREAM=https://github.com/h2o/h2o/archive/v2.0.4.tar.gz + +all: libssl bin/h2o images + +bin/h2o: build/build/h2o + mkdir -p bin + cp $< $@ + +build/build/h2o: build/build/Makefile + $(MAKE) -C build/build + +build/build/Makefile: build/stamp_patch + mkdir -p build/build + (cd build/build && \ + cmake -DCMAKE_TOOLCHAIN_FILE=${RUMPRUN_CMAKE_TOOLCHAIN_FILE} \ + -DOPENSSL_INCLUDE_DIR=${RUMPRUN_PKGS_DIR}/include \ + -DOPENSSL_SSL_LIBRARY=${RUMPRUN_PKGS_DIR}/lib/libssl.a \ + -DOPENSSL_CRYPTO_LIBRARY=${RUMPRUN_PKGS_DIR}/lib/libcrypto.a \ + ..) + +build/stamp_patch: build/CMakeLists.txt + (cd build && ../../scripts/apply-patches.sh ./ ../patches/*) + touch $@ + +build/CMakeLists.txt: + mkdir -p build + ../scripts/fetch.sh $(UPSTREAM) build/h2o.tar.gz + (cd build && tar -xz --strip-components 1 -f h2o.tar.gz) + +.PHONY: images +images: images/data.iso + +images/data.iso: images/data/conf/* images/data/www/* + $(RUMPRUN_GENISOIMAGE) -o images/data.iso images/data + +.PHONY: clean +clean: + $(MAKE) -C build/build clean + rm -f bin/* + rm -f images/data.iso +distclean: clean + rm -rf build/build + +include ../Makefile.deps diff --git a/h2o/README.md b/h2o/README.md new file mode 100644 index 00000000..6603fabd --- /dev/null +++ b/h2o/README.md @@ -0,0 +1,38 @@ +Overview +======== + +Packaging of the [h2o](http://h2o.examp1e.net/) 2.0.4 HTTP server for rumprun. + +Instructions +============ + +The build script also requires `genisoimage` in order to build the ISO image +for `/data`. + +Run `make`: + +``` +make +``` + +Bake the final unikernel image: +``` +rumprun-bake xen_pv bin/h2o.bin bin/h2o +``` + +(Replace `xen_pv` with the platform you are baking for.) + +Examples +======== + +To start a Xen domU running h2o serving static files, as root run (for +example): + +```` +rumprun xen -M 128 -di \ + -n inet,static,10.10.10.10/24 \ + -b images/data.iso,/data \ + -- bin/h2o.bin -c /data/conf/h2o.conf +```` + +Replace `10.10.10.10/24` with a valid IP address on your Xen network. diff --git a/h2o/h2o.conf b/h2o/h2o.conf new file mode 100644 index 00000000..b59ef9cd --- /dev/null +++ b/h2o/h2o.conf @@ -0,0 +1,9 @@ +# to find out the configuration commands, run: h2o --help + +listen: 80 +hosts: + "127.0.0.1:80": + paths: + /: + file.dir: /data/www + access-log: /dev/stdout diff --git a/h2o/images/data/conf/h2o.conf b/h2o/images/data/conf/h2o.conf new file mode 100644 index 00000000..16d58b53 --- /dev/null +++ b/h2o/images/data/conf/h2o.conf @@ -0,0 +1,7 @@ +listen: 80 +hosts: + "127.0.0.1:80": + paths: + /: + file.dir: /data/www + access-log: /dev/stdout diff --git a/h2o/images/data/www/index.html b/h2o/images/data/www/index.html new file mode 100644 index 00000000..2d8ed62f --- /dev/null +++ b/h2o/images/data/www/index.html @@ -0,0 +1,10 @@ + + + + Welcome to H2O + + +

Welcome to H2O - an optimized HTTP server

+

It works!

+ + diff --git a/h2o/patches/CMakeLists.diff b/h2o/patches/CMakeLists.diff new file mode 100644 index 00000000..8c808fad --- /dev/null +++ b/h2o/patches/CMakeLists.diff @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt 2016-10-31 09:06:07.808933060 +0000 ++++ b/CMakeLists.txt 2016-10-31 09:06:18.929110957 +0000 +@@ -313,7 +313,7 @@ + lib/http2/hpack.c + lib/http2/scheduler.c) + +-SET(EXTRA_LIBS ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) ++SET(EXTRA_LIBS ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + + IF (ZLIB_FOUND) + LIST(INSERT EXTRA_LIBS 0 ${ZLIB_LIBRARIES})