-
Notifications
You must be signed in to change notification settings - Fork 66
/
Dockerfile
83 lines (62 loc) · 2.57 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
FROM ocaml/opam:alpine-3.13-ocaml-4.12 as compilation
LABEL Description="learn-ocaml building" Vendor="OCamlPro"
WORKDIR /home/opam/learn-ocaml
COPY learn-ocaml.opam learn-ocaml.opam.locked learn-ocaml-client.opam learn-ocaml-client.opam.locked ./
RUN sudo chown -R opam:nogroup .
ENV OPAMYES true
RUN echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config \
&& opam repository set-url default http://opam.ocaml.org \
&& opam switch 4.12 \
&& echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config \
&& opam install . --deps-only --locked
COPY static static
COPY translations translations
COPY src src
COPY scripts scripts
COPY Makefile Makefile
COPY demo-repository demo-repository
COPY dune-project dune-project
COPY dune dune
RUN sudo chown -R opam:nogroup .
ENV OPAMVERBOSE 1
RUN cat /proc/cpuinfo /proc/meminfo
RUN opam install . --destdir /home/opam/install-prefix --locked
FROM alpine:3.13 as client
RUN apk update \
&& apk add ncurses-libs libev dumb-init openssl \
&& addgroup learn-ocaml \
&& adduser learn-ocaml -DG learn-ocaml
VOLUME ["/learnocaml"]
USER learn-ocaml
WORKDIR /learnocaml
COPY --from=compilation /home/opam/install-prefix/bin/learn-ocaml-client /usr/bin
ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml-client"]
FROM alpine:3.13 as program
RUN apk update \
&& apk add ncurses-libs libev dumb-init git openssl lsof \
&& addgroup learn-ocaml \
&& adduser learn-ocaml -DG learn-ocaml
VOLUME ["/repository"]
RUN mkdir -p /sync && chown learn-ocaml:learn-ocaml /sync
VOLUME ["/sync"]
EXPOSE 8080
EXPOSE 8443
USER learn-ocaml
WORKDIR /home/learn-ocaml
ARG opam_switch="/home/opam/.opam/4.12"
COPY --from=compilation /home/opam/install-prefix /usr
COPY --from=compilation "$opam_switch/bin"/ocaml* "$opam_switch/bin/"
COPY --from=compilation "$opam_switch/lib/ocaml" "$opam_switch/lib/ocaml/"
COPY --from=compilation "$opam_switch/bin/js_of_ocaml" "$opam_switch/bin/"
COPY --from=compilation "$opam_switch/lib/js_of_ocaml" "$opam_switch/lib/js_of_ocaml"
COPY --from=compilation "$opam_switch/lib/vg" "$opam_switch/lib/vg"
COPY --from=compilation "$opam_switch/lib/gg" "$opam_switch/lib/gg"
# Fixes for ocamlfind
COPY --from=compilation "$opam_switch/lib/findlib.conf" "$opam_switch/lib/"
COPY --from=compilation "$opam_switch/lib/stdlib" "$opam_switch/lib/stdlib"
ENV PATH="${opam_switch}/bin:${PATH}"
ENV OCAMLPATH="/usr/lib"
RUN ln -sf "$opam_switch/lib/vg" "/usr/lib"
RUN ln -sf "$opam_switch/lib/gg" "/usr/lib"
ENTRYPOINT ["dumb-init","/usr/bin/learn-ocaml","--sync-dir=/sync","--repo=/repository"]
CMD ["build","serve"]