From 5802ae011093ca4e138ad82fcd0ee14bbcc6f20f Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Mon, 4 Dec 2023 19:33:34 -0600 Subject: Add nix --- Dockerfile | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 93d745d..130cb27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,22 @@ -FROM ocaml/opam:alpine as build +FROM nixos/nix:latest AS builder # Install system dependencies -RUN sudo apk add --update libev-dev openssl-dev gmp-dev gmp -WORKDIR /home/opam +COPY . /tmp/build +WORKDIR /tmp/build -# Install dependencies -ADD wormhole.opam wormhole.opam -RUN opam install . --deps-only +RUN nix \ + --extra-experimental-features "nix-command flakes" \ + --option filter-syscalls false \ + build -# Build project -ADD . . -RUN opam exec -- dune build -j 1 +RUN mkdir /tmp/nix-store-closure +RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure +FROM scratch -FROM alpine:3.18.4 as run +WORKDIR /app -RUN apk add --update libev openssl gmp - -COPY --from=build /home/opam/_build/default/bin/main.exe /bin/app - -ENTRYPOINT /bin/app +# Copy /nix/store +COPY --from=builder /tmp/nix-store-closure /nix/store +COPY --from=builder /tmp/build/result/ /app +ENTRYPOINT /app/bin/wormhole -- cgit v1.2.3