-
Notifications
You must be signed in to change notification settings - Fork 330
/
Dockerfile
57 lines (42 loc) · 1.6 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
FROM ocaml/opam:alpine-3.19-ocaml-5.2 AS build
# Install system dependencies
RUN sudo apk -U upgrade --no-cache && sudo apk add --no-cache \
autoconf \
curl-dev \
gmp-dev \
inotify-tools \
libev-dev \
oniguruma-dev \
openssl-dev
# Branch freeze was opam-repo HEAD at the time of commit
RUN cd ~/opam-repository && git reset --hard c45f5bab71d3589f41f9603daca5acad14df0ab0 && opam update
WORKDIR /home/opam
# Install opam dependencies
COPY --chown=opam ocamlorg.opam .
RUN opam install . --deps-only
# Build project
COPY --chown=opam . .
RUN opam exec -- dune build @install --profile=release
# Launch project in order to generate the package state cache
RUN cd ~/opam-repository && git checkout master && git pull origin master && opam update
ENV OCAMLORG_PKG_STATE_PATH=package.state \
OCAMLORG_REPO_PATH=opam-repository
RUN touch package.state && ./init-cache package.state
FROM alpine:3.19
RUN apk -U upgrade --no-cache && apk add --no-cache \
git \
gmp \
libev
COPY --from=build /home/opam/package.state /var/package.state
COPY --from=build /home/opam/opam-repository /var/opam-repository
COPY --from=build /home/opam/_build/default/src/ocamlorg_web/bin/main.exe /bin/server
COPY playground/asset playground/asset
RUN git clone https://github.com/ocaml-web/html-compiler-manuals /manual
RUN git config --global --add safe.directory /var/opam-repository
ENV DREAM_VERBOSITY=info \
OCAMLORG_HTTP_PORT=8080 \
OCAMLORG_MANUAL_PATH=/manual \
OCAMLORG_PKG_STATE_PATH=/var/package.state \
OCAMLORG_REPO_PATH=/var/opam-repository/
EXPOSE 8080
ENTRYPOINT ["/bin/server"]