Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: a1a3de646ffdb7811c65d747617d6f735aab1219
Timestamp: Tue, 25 Aug 2020 17:17:53 +0000 (4 years ago)

+76 -0 +/-4 browse
add dockerfiles & supporting scripts
1diff --git a/.dockerignore b/.dockerignore
2new file mode 100644
3index 0000000..69fa449
4--- /dev/null
5+++ b/.dockerignore
6 @@ -0,0 +1 @@
7+ _build/
8 diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine
9new file mode 100644
10index 0000000..be48236
11--- /dev/null
12+++ b/docker/Dockerfile.alpine
13 @@ -0,0 +1,35 @@
14+ FROM ocaml/opam2:alpine
15+
16+ USER root
17+
18+ RUN apk --update-cache add m4 linux-headers
19+
20+ # install dependencies first to avoid re-installation
21+ # when the a non-opam file in the repository changes.
22+
23+ COPY note.opam /src/
24+
25+ USER opam
26+
27+ RUN opam repository set-url default https://opam.ocaml.org \
28+ && cd /src \
29+ && opam install dune \
30+ && opam install --deps-only .
31+
32+ USER root
33+
34+ COPY . /src/
35+
36+ RUN chown -R opam:opam /src
37+
38+ USER opam
39+
40+ RUN cd /src \
41+ && eval "$(opam env)" \
42+ && dune build
43+
44+ FROM alpine:latest
45+
46+ COPY --from=0 /src/_build/default/bin/note.exe /usr/bin/note
47+
48+ ENTRYPOINT ["/usr/bin/note"]
49 diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian
50new file mode 100644
51index 0000000..3c3e749
52--- /dev/null
53+++ b/docker/Dockerfile.debian
54 @@ -0,0 +1,35 @@
55+ FROM ocaml/opam2:debian-stable
56+
57+ USER root
58+
59+ RUN apt-get update && apt-get install -yyq linux-headers-amd64 m4 pkg-config
60+
61+ # install dependencies first to avoid re-installation
62+ # when the a non-opam file in the repository changes.
63+
64+ COPY note.opam /src/
65+
66+ USER opam
67+
68+ RUN opam repository set-url default https://opam.ocaml.org \
69+ && cd /src \
70+ && opam install dune \
71+ && opam install --deps-only .
72+
73+ USER root
74+
75+ COPY . /src/
76+
77+ RUN chown -R opam:opam /src
78+
79+ USER opam
80+
81+ RUN cd /src \
82+ && eval "$(opam env)" \
83+ && dune build
84+
85+ FROM debian:stable
86+
87+ COPY --from=0 /src/_build/default/bin/note.exe /usr/bin/note
88+
89+ ENTRYPOINT ["/usr/bin/note"]
90 diff --git a/scripts/build_docker.sh b/scripts/build_docker.sh
91new file mode 100755
92index 0000000..297356c
93--- /dev/null
94+++ b/scripts/build_docker.sh
95 @@ -0,0 +1,5 @@
96+ #!/bin/bash
97+ set -e
98+
99+ docker build -t note-alpine -f docker/Dockerfile.alpine .
100+ docker build -t note-debian -f docker/Dockerfile.debian .