sdk: fix dhcp's Dockerfile

The rootfs were containing way too much binaries and runc command where not
started in the correct directory.

Signed-off-by: Thomas Gazagnaire <thomas@gazagnaire.org>
This commit is contained in:
Thomas Gazagnaire 2017-06-14 16:13:40 +01:00
parent 6fb3820925
commit e76d6c09a4
5 changed files with 15 additions and 12 deletions

View File

@ -56,7 +56,6 @@ RUN opam update sdk && opam install sdk -t
FROM sdk as priv FROM sdk as priv
RUN opam pin add tuntap 1.0.0 -n
RUN opam depext -iy bos cmdliner RUN opam depext -iy bos cmdliner
RUN opam list RUN opam list
@ -65,8 +64,8 @@ COPY ./dhcp-client /src/dhcp-client
RUN sudo chown opam -R /src RUN sudo chown opam -R /src
RUN opam config exec -- jbuilder build dhcp-client/main.exe RUN opam config exec -- jbuilder build dhcp-client/main.exe
RUN sudo mkdir -p /bin RUN sudo mkdir -p /out
RUN sudo cp /src/_build/default/dhcp-client/main.exe /bin/dhcp-client RUN sudo cp /src/_build/default/dhcp-client/main.exe /out/dhcp-client
### Calf Container ### Calf Container
@ -85,15 +84,15 @@ COPY ./dhcp-client-calf/jbuild /src/dhcp-client-calf/
RUN sudo chown opam -R /src RUN sudo chown opam -R /src
RUN opam config exec -- jbuilder build dhcp-client-calf/unikernel.exe RUN opam config exec -- jbuilder build dhcp-client-calf/unikernel.exe
RUN sudo mkdir -p /bin/calf RUN sudo mkdir -p /out/
RUN sudo cp /src/_build/default/dhcp-client-calf/unikernel.exe /bin/calf/dhcp-client-calf RUN sudo cp /src/_build/default/dhcp-client-calf/unikernel.exe /out/dhcp-client-calf
USER 0
### Final build ### Final build
FROM scratch FROM scratch
COPY --from=priv /bin / USER 0
COPY --from=calf /bin / COPY --from=priv /out /
COPY dhcp-client-calf/config.json /calf/ COPY --from=calf /out /calf/rootfs/
COPY dhcp-client-calf/config.json /calf
CMD ["/dhcp-client", "-vv"] CMD ["/dhcp-client", "-vv"]

View File

@ -17,7 +17,7 @@
} }
}, },
"root": { "root": {
"path": "calf", "path": "rootfs",
"readonly": true "readonly": true
}, },
"mounts": [ "mounts": [

View File

@ -60,7 +60,7 @@ let default_cmd = [
*) *)
let default_cmd = [ let default_cmd = [
"/usr/bin/runc"; "run"; "--preserve-fds"; "2"; "--bundle"; "."; "calf" "/usr/bin/runc"; "run"; "--preserve-fds"; "2"; "--bundle"; "calf"; "calf"
] ]
let read_cmd file = let read_cmd file =

View File

@ -23,7 +23,7 @@ depends: [
"decompress" "decompress"
"capnp-rpc-lwt" "capnp-rpc-lwt"
"rawlink" "rawlink"
"tuntap" "tuntap" {= "1.0.0"}
"ipaddr" "ipaddr"
"alcotest" {test} "alcotest" {test}
] ]

View File

@ -2,8 +2,12 @@
open Lwt.Infix open Lwt.Infix
let src = Logs.Src.create "net" ~doc:"Network Configuration"
module Log = (val Logs.src_log src : Logs.LOG)
let run fmt = let run fmt =
Fmt.kstrf (fun str -> Fmt.kstrf (fun str ->
Log.info (fun l -> l "run: %S" str);
match Sys.command str with match Sys.command str with
| 0 -> Lwt.return () | 0 -> Lwt.return ()
| i -> Fmt.kstrf Lwt.fail_with "%S exited with code %d" str i | i -> Fmt.kstrf Lwt.fail_with "%S exited with code %d" str i