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

View File

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

View File

@ -60,7 +60,7 @@ 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 =

View File

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

View File

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