This commit is contained in:
parent
e02c4a11a7
commit
d6dc26664c
13 changed files with 100 additions and 19 deletions
18
.gitignore
vendored
18
.gitignore
vendored
|
|
@ -1,8 +1,12 @@
|
||||||
_build/
|
_build/
|
||||||
mirage/
|
data/tls/keys/**
|
||||||
dist/
|
!data/tls/keys/.gitkeep
|
||||||
dune.build
|
data/tls/certificates/**
|
||||||
dune.config
|
!data/tls/certificates/.gitkeep
|
||||||
dune-project
|
unikernel/mirage/
|
||||||
dune-workspace
|
unikernel/dist/
|
||||||
duniverse/
|
unikernel/dune.build
|
||||||
|
unikernel/dune.config
|
||||||
|
unikernel/dune-project
|
||||||
|
unikernel/dune-workspace
|
||||||
|
unikernel/duniverse/
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
dist/dune
|
unikernel/dist/*
|
||||||
|
unikernel/mirage/*
|
||||||
|
|
|
||||||
64
Makefile
Normal file
64
Makefile
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
# Generated by mirage.v4.10.3
|
||||||
|
|
||||||
|
-include Makefile.user
|
||||||
|
BUILD_DIR = unikernel/
|
||||||
|
MIRAGE_DIR = unikernel/mirage
|
||||||
|
UNIKERNEL_NAME = mte-unix
|
||||||
|
OPAM = opam
|
||||||
|
|
||||||
|
all::
|
||||||
|
@$(MAKE) --no-print-directory depends
|
||||||
|
@$(MAKE) --no-print-directory build
|
||||||
|
|
||||||
|
.PHONY: all lock install-switch pull clean depend depends build repo-add repo-rm depext-lockfile
|
||||||
|
|
||||||
|
repo-add:
|
||||||
|
@printf "\033[2musing overlay repository mirage: [opam-overlays, mirage-overlays] \033[0m\n"
|
||||||
|
$(OPAM) repo add opam-overlays https://github.com/dune-universe/opam-overlays.git || $(OPAM) repo set-url opam-overlays https://github.com/dune-universe/opam-overlays.git
|
||||||
|
$(OPAM) repo add mirage-overlays https://github.com/dune-universe/mirage-opam-overlays.git || $(OPAM) repo set-url mirage-overlays https://github.com/dune-universe/mirage-opam-overlays.git
|
||||||
|
|
||||||
|
|
||||||
|
repo-rm:
|
||||||
|
@printf "\033[2mremoving overlay repository [opam-overlays, mirage-overlays]\033[0m\n"
|
||||||
|
$(OPAM) repo remove opam-overlays https://github.com/dune-universe/opam-overlays.git
|
||||||
|
$(OPAM) repo remove mirage-overlays https://github.com/dune-universe/mirage-opam-overlays.git
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
depext-lockfile: $(MIRAGE_DIR)/$(UNIKERNEL_NAME).opam.locked
|
||||||
|
echo " ↳ install external dependencies for monorepo"
|
||||||
|
env OPAMVAR_monorepo="opam-monorepo" $(OPAM) monorepo depext -y -l $<
|
||||||
|
|
||||||
|
|
||||||
|
$(MIRAGE_DIR)/$(UNIKERNEL_NAME).opam.locked: $(MIRAGE_DIR)/$(UNIKERNEL_NAME).opam
|
||||||
|
@$(MAKE) -s repo-add
|
||||||
|
@echo " ↳ generate lockfile for monorepo dependencies"
|
||||||
|
@env OPAMVAR_monorepo="opam-monorepo" $(OPAM) monorepo lock --require-cross-compile --build-only $(UNIKERNEL_NAME) -l $@ --ocaml-version $(shell ocamlc --version); (ret=$$?; $(MAKE) -s repo-rm && exit $$ret)
|
||||||
|
|
||||||
|
lock::
|
||||||
|
@$(MAKE) -B $(MIRAGE_DIR)/$(UNIKERNEL_NAME).opam.locked
|
||||||
|
@echo "The lock file has been generated. Run 'make pull' to retrieve the sources, or 'make install-switch' to install the host dependencies."
|
||||||
|
|
||||||
|
pull:: $(MIRAGE_DIR)/$(UNIKERNEL_NAME).opam.locked
|
||||||
|
@echo " ↳ fetch monorepo dependencies in the duniverse folder"
|
||||||
|
@env OPAMVAR_monorepo="opam-monorepo" $(OPAM) monorepo pull -l $< -r $(abspath $(BUILD_DIR))
|
||||||
|
@echo "The sources have been pulled to the duniverse folder. Run 'make build' to build the unikernel."
|
||||||
|
|
||||||
|
install-switch:: $(MIRAGE_DIR)/$(UNIKERNEL_NAME).opam
|
||||||
|
@echo " ↳ opam install switch dependencies"
|
||||||
|
@$(OPAM) install $< --deps-only --yes
|
||||||
|
@$(MAKE) -s depext-lockfile
|
||||||
|
@echo "The dependencies have been installed. Run 'make build' to build the unikernel."
|
||||||
|
|
||||||
|
depends depend::
|
||||||
|
@$(MAKE) --no-print-directory lock
|
||||||
|
@$(MAKE) --no-print-directory install-switch
|
||||||
|
@$(MAKE) --no-print-directory pull
|
||||||
|
|
||||||
|
build::
|
||||||
|
dune build --profile release --root . $(BUILD_DIR)dist
|
||||||
|
@echo "Your unikernel binary is now ready in $(BUILD_DIR)dist/mte"
|
||||||
|
@echo "Execute the binary using solo5-hvt, solo5-spt, xl, ..."
|
||||||
|
|
||||||
|
clean::
|
||||||
|
mirage clean
|
||||||
0
data/tls/.gitkeep
Normal file
0
data/tls/.gitkeep
Normal file
7
dune-project
Normal file
7
dune-project
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
(lang dune 2.9)
|
||||||
|
|
||||||
|
(name mte-unix)
|
||||||
|
|
||||||
|
(implicit_transitive_deps true)
|
||||||
|
|
||||||
|
;; Generated by mirage.v4.10.3
|
||||||
5
dune-workspace
Normal file
5
dune-workspace
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
(lang dune 2.9)
|
||||||
|
|
||||||
|
(context (default))
|
||||||
|
|
||||||
|
;; Generated by mirage.v4.10.3
|
||||||
|
|
@ -2,4 +2,6 @@
|
||||||
|
|
||||||
hostname="${2:-localhost}"
|
hostname="${2:-localhost}"
|
||||||
|
|
||||||
|
mkdir data/tls/keys
|
||||||
|
mkdir data/tls/certificates
|
||||||
openssl req -x509 -newkey rsa:4096 -keyout data/tls/keys/$1 -out data/tls/certificates/$1 -sha256 -days 365 -subj "/CN=$hostname" -nodes
|
openssl req -x509 -newkey rsa:4096 -keyout data/tls/keys/$1 -out data/tls/certificates/$1 -sha256 -days 365 -subj "/CN=$hostname" -nodes
|
||||||
|
|
|
||||||
5
src/dune
5
src/dune
|
|
@ -1,5 +1,4 @@
|
||||||
(library
|
(library
|
||||||
(wrapped false)
|
|
||||||
(name mte)
|
(name mte)
|
||||||
(public_name mte)
|
(wrapped false)
|
||||||
(libraries logs hxd.core hxd.string))
|
(libraries logs))
|
||||||
|
|
|
||||||
1
src/mte.ml
Normal file
1
src/mte.ml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
let uuu = "uuu"
|
||||||
|
|
@ -5,8 +5,8 @@ type conn = Connect
|
||||||
|
|
||||||
let conn = typ Connect
|
let conn = typ Connect
|
||||||
|
|
||||||
let minipaf =
|
let mte =
|
||||||
main "Unikernel.Make"
|
main "Unikernel.Make" ~local_libs:[ "mte" ]
|
||||||
~packages:
|
~packages:
|
||||||
[
|
[
|
||||||
package "digestif"; package ~min:"0.0.9" "mimic-happy-eyeballs";
|
package "digestif"; package ~min:"0.0.9" "mimic-happy-eyeballs";
|
||||||
|
|
@ -27,8 +27,8 @@ let stackv4v6 = generic_stackv4v6 default_network
|
||||||
let tcpv4v6 = tcpv4v6_of_stackv4v6 stackv4v6
|
let tcpv4v6 = tcpv4v6_of_stackv4v6 stackv4v6
|
||||||
let he = generic_happy_eyeballs stackv4v6
|
let he = generic_happy_eyeballs stackv4v6
|
||||||
let dns = generic_dns_client stackv4v6 he
|
let dns = generic_dns_client stackv4v6 he
|
||||||
let certificates = crunch "data/tls/certificates"
|
let certificates = crunch "../data/tls/certificates"
|
||||||
let keys = crunch "data/tls/keys"
|
let keys = crunch "../data/tls/keys"
|
||||||
|
|
||||||
let conn =
|
let conn =
|
||||||
let happy_eyeballs = mimic_happy_eyeballs stackv4v6 he dns in
|
let happy_eyeballs = mimic_happy_eyeballs stackv4v6 he dns in
|
||||||
|
|
@ -38,5 +38,4 @@ let port = Runtime_arg.create ~pos:__POS__ "Unikernel.port"
|
||||||
let http_server = paf_server ~port tcpv4v6
|
let http_server = paf_server ~port tcpv4v6
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
register "minipaf"
|
register "mte" [ mte $ certificates $ keys $ tcpv4v6 $ conn $ http_server ]
|
||||||
[ minipaf $ certificates $ keys $ tcpv4v6 $ conn $ http_server ]
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
open Rresult
|
open Rresult
|
||||||
open Lwt.Infix
|
open Lwt.Infix
|
||||||
open Cmdliner
|
open Cmdliner
|
||||||
open Mte
|
|
||||||
|
|
||||||
let port =
|
let port =
|
||||||
let doc = Arg.info ~doc:"Port of HTTP service." [ "p"; "port" ] in
|
let doc = Arg.info ~doc:"Port of HTTP service." [ "p"; "port" ] in
|
||||||
Arg.(value & opt int 8080 doc)
|
Arg.(value & opt int 3434 doc)
|
||||||
|
|
||||||
let use_tls =
|
let use_tls =
|
||||||
let doc =
|
let doc =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue