diff --git a/library/findtime/master/Cargo.toml.patch b/library/findtime/master/Cargo.toml.patch new file mode 100644 index 00000000..fa88c64d --- /dev/null +++ b/library/findtime/master/Cargo.toml.patch @@ -0,0 +1,9 @@ +diff --git a/Cargo.toml b/Cargo.toml +index 6b99267..3d0863b 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -18,3 +18,4 @@ chrono = "0.4.31" + log = "0.4" + env_logger = "0.10" + rand = "0.8.5" ++openssl = { version = "0.10.60", features = ["vendored"] } diff --git a/library/findtime/master/Dockerfile b/library/findtime/master/Dockerfile new file mode 100644 index 00000000..7bbe9e67 --- /dev/null +++ b/library/findtime/master/Dockerfile @@ -0,0 +1,36 @@ +FROM rust:1.73.0-bookworm AS build + +WORKDIR /src + +RUN set -xe; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + wget \ + xz-utils \ + musl-dev \ + musl-tools \ + patch \ + git; \ + git clone https://github.com/fbergen/findtime \ + ; + +WORKDIR /src/findtime +COPY Cargo.toml.patch /src/findtime +COPY listen_address.patch /src/findtime + +RUN set -xe; \ + patch -p1 < Cargo.toml.patch; \ + patch -p1 < listen_address.patch; \ + rustup target add x86_64-unknown-linux-musl; \ + cargo build --release --target=x86_64-unknown-linux-musl \ + ; + +COPY ./resolv.conf /tmp/resolv.conf + +FROM scratch + +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=build /src/findtime/target/x86_64-unknown-linux-musl/release/findtime /findtime +COPY --from=build /src/findtime/index.html /src/findtime/main.js / +COPY --from=build /tmp/resolv.conf /etc/resolv.conf diff --git a/library/findtime/master/Kraftfile b/library/findtime/master/Kraftfile new file mode 100644 index 00000000..e9dd9c35 --- /dev/null +++ b/library/findtime/master/Kraftfile @@ -0,0 +1,128 @@ +spec: v0.6 + +name: findtime + +rootfs: ./Dockerfile + +cmd: ["/findtime"] + +template: + source: https://github.com/unikraft/app-elfloader + version: staging + +unikraft: + source: https://github.com/unikraft/unikraft + version: base + kconfig: + CONFIG_APPELFLOADER_ARCH_PRCTL: 'y' + CONFIG_APPELFLOADER_BRK: 'y' + CONFIG_APPELFLOADER_CUSTOMAPPNAME: 'y' + CONFIG_APPELFLOADER_STACK_NBPAGES: 128 + CONFIG_APPELFLOADER_VFSEXEC_EXECBIT: 'n' + CONFIG_APPELFLOADER_VFSEXEC: 'y' + CONFIG_HAVE_PAGING_DIRECTMAP: 'y' + CONFIG_HAVE_PAGING: 'y' + CONFIG_I8042: 'y' + CONFIG_LIBDEVFS_AUTOMOUNT: 'y' + CONFIG_LIBDEVFS_DEV_NULL: 'y' + CONFIG_LIBDEVFS_DEV_STDOUT: 'y' + CONFIG_LIBDEVFS_DEV_ZERO: 'y' + CONFIG_LIBDEVFS: 'y' + CONFIG_LIBPOSIX_ENVIRON_ENVP0: "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + CONFIG_LIBPOSIX_ENVIRON_ENVP1: "LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib" + CONFIG_LIBPOSIX_ENVIRON_ENVP2: "HOME=/" + CONFIG_LIBPOSIX_ENVIRON: 'y' + CONFIG_LIBPOSIX_EVENTFD: 'y' + CONFIG_LIBPOSIX_FDIO: 'y' + CONFIG_LIBPOSIX_FDTAB: 'y' + CONFIG_LIBPOSIX_FUTEX: 'y' + CONFIG_LIBPOSIX_MMAP: 'y' + CONFIG_LIBPOSIX_NETLINK: 'y' + CONFIG_LIBPOSIX_PIPE: 'y' + CONFIG_LIBPOSIX_POLL: 'y' + CONFIG_LIBPOSIX_PROCESS_CLONE: 'y' + CONFIG_LIBPOSIX_SOCKET: 'y' + CONFIG_LIBPOSIX_SYSINFO: 'y' + CONFIG_LIBPOSIX_TIME: 'y' + CONFIG_LIBPOSIX_TIMERFD: 'y' + CONFIG_LIBPOSIX_UNIXSOCKET: 'y' + CONFIG_LIBPOSIX_USER_GID: 0 + CONFIG_LIBPOSIX_USER_GROUPNAME: "root" + CONFIG_LIBPOSIX_USER_UID: 0 + CONFIG_LIBPOSIX_USER_USERNAME: "root" + CONFIG_LIBPOSIX_USER: 'y' + CONFIG_LIBRAMFS: 'y' + CONFIG_LIBSYSCALL_SHIM_HANDLER_ULTLS: 'y' + CONFIG_LIBSYSCALL_SHIM_HANDLER: 'y' + CONFIG_LIBSYSCALL_SHIM_LEGACY_VERBOSE: 'y' + CONFIG_LIBSYSCALL_SHIM: 'y' + CONFIG_LIBUKALLOCPOOL: 'y' + CONFIG_LIBUKBLKDEV_SYNC_IO_BLOCKED_WAITING: 'y' + CONFIG_LIBUKBLKDEV: 'y' + CONFIG_LIBUKBOOT_BANNER_MINIMAL: 'y' + CONFIG_LIBUKBOOT_HEAP_BASE: '0x400000000' + CONFIG_LIBUKBOOT_SHUTDOWNREQ_HANDLER: 'y' + CONFIG_LIBUKCPIO: 'y' + CONFIG_LIBUKDEBUG_CRASH_SCREEN: 'y' + CONFIG_LIBUKDEBUG_ENABLE_ASSERT: 'y' + CONFIG_LIBUKDEBUG_PRINT_SRCNAME: 'n' + CONFIG_LIBUKDEBUG_PRINT_TIME: 'y' + CONFIG_LIBUKDEBUG_PRINTK_ERR: 'y' + CONFIG_LIBUKDEBUG_PRINTK: 'y' + CONFIG_LIBUKDEBUG: 'y' + CONFIG_LIBUKFALLOC: 'y' + CONFIG_LIBUKMPI: 'n' + CONFIG_LIBUKSIGNAL: 'y' + CONFIG_LIBUKSWRAND_DEVFS: 'y' + CONFIG_LIBUKSWRAND: 'y' + CONFIG_LIBUKVMEM_DEFAULT_BASE: '0x0000001000000000' + CONFIG_LIBUKVMEM_DEMAND_PAGE_IN_SIZE: 12 + CONFIG_LIBUKVMEM_PAGEFAULT_HANDLER_PRIO: 4 + CONFIG_LIBUKVMEM: 'y' + CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS: 'y' # needed for einitrd + CONFIG_LIBVFSCORE_FSTAB: 'y' + CONFIG_LIBVFSCORE_NONLARGEFILE: 'y' + CONFIG_LIBVFSCORE_ROOTFS_EINITRD: 'y' + CONFIG_LIBVFSCORE: 'y' + CONFIG_OPTIMIZE_DEADELIM: 'y' + CONFIG_OPTIMIZE_LTO: 'y' + CONFIG_PAGING: 'y' + CONFIG_STACK_SIZE_PAGE_ORDER: 4 # 128 * 4K = 512K + CONFIG_UKPLAT_KSP_SIZE: 32768 + CONFIG_UKPLAT_MEMREGION_MAX_COUNT: 64 + + # Debug options + # CONFIG_LIBUKDEBUG_PRINTD: 'y' + # CONFIG_LIBUKDEBUG_PRINTK_INFO: 'y' + # CONFIG_LIBSYSCALL_SHIM_STRACE: 'y' + +libraries: + lwip: + source: https://github.com/unikraft/lib + version: stable + kconfig: + CONFIG_LWIP_LOOPIF: 'y' + CONFIG_LWIP_UKNETDEV: 'y' + CONFIG_LWIP_LOOPBACK: 'y' + CONFIG_LWIP_TCP: 'y' + CONFIG_LWIP_UDP: 'y' + CONFIG_LWIP_RAW: 'y' + CONFIG_LWIP_WND_SCALE: 'y' + CONFIG_LWIP_TCP_KEEPALIVE: 'y' + CONFIG_LWIP_THREADS: 'y' + CONFIG_LWIP_HEAP: 'y' + CONFIG_LWIP_SOCKET: 'y' + CONFIG_LWIP_AUTOIFACE: 'y' + CONFIG_LWIP_IPV4: 'y' + CONFIG_LWIP_DHCP: 'n' + CONFIG_LWIP_DNS: 'n' + CONFIG_LWIP_NUM_TCPCON: 64 + CONFIG_LWIP_NUM_TCPLISTENERS: 64 + CONFIG_LWIP_ICMP: 'y' + libelf: + source: https://github.com/unikraft/lib-libelf.git + version: stable + +targets: +- qemu/x86_64 +- fc/x86_64 diff --git a/library/findtime/master/Makefile b/library/findtime/master/Makefile new file mode 100644 index 00000000..ec37ff8b --- /dev/null +++ b/library/findtime/master/Makefile @@ -0,0 +1,3 @@ +IMAGE_NAME = unikraft-findtime + +include ../../../utils/bincompat/docker.Makefile diff --git a/library/findtime/master/README.md b/library/findtime/master/README.md new file mode 100644 index 00000000..e89c5e74 --- /dev/null +++ b/library/findtime/master/README.md @@ -0,0 +1,15 @@ +# Findtime Image + +This directory contains the definition for the `unikraft.org/findtime:master` image. + +To run this image, [install Unikraft's companion command-line toolchain `kraft`](https://unikraft.org/docs/cli) and then you can run: + +``` +kraft run -p 8080:8080 unikraft.org/findtime:master +``` + +Once executed you will be able to access the web interface at http://localhost:8080 + +## See also + +- [How to run unikernels locally in Unikraft's Documentation](https://unikraft.org/docs/cli/running). diff --git a/library/findtime/master/listen_address.patch b/library/findtime/master/listen_address.patch new file mode 100644 index 00000000..f597e39c --- /dev/null +++ b/library/findtime/master/listen_address.patch @@ -0,0 +1,13 @@ +diff --git a/src/main.rs b/src/main.rs +index e6a7d31..5459abf 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -136,7 +136,7 @@ async fn main() -> std::io::Result<()> { + + info!("Main started"); + +- let address = env::var("ADDRESS").unwrap_or_else(|_| "127.0.0.1".to_string()); ++ let address = env::var("ADDRESS").unwrap_or_else(|_| "0.0.0.0".to_string()); + let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string()); + info!("Listening on {}:{}", address, port); +