-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Should speed up builds a bit.
- Loading branch information
Showing
1 changed file
with
35 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,59 @@ | ||
FROM ocaml/opam:alpine-3.20-ocaml-5.2 as build | ||
# syntax=docker/dockerfile:1 | ||
FROM ocaml/opam:alpine-3.20-ocaml-5.2 AS build | ||
|
||
# Install system dependencies | ||
RUN sudo apk update && sudo apk add --update libev-dev openssl-dev gmp-dev oniguruma-dev inotify-tools curl-dev autoconf | ||
RUN 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 pull origin c45f5bab71d3589f41f9603daca5acad14df0ab0 && opam update | ||
RUN cd ~/opam-repository && git fetch -q origin master && git reset --hard 11bdbee61114a1cfa080b764e71c72a5760a93f0 && opam update | ||
|
||
WORKDIR /home/opam | ||
|
||
# Install Opam dependencies | ||
ADD ocamlorg.opam ocamlorg.opam | ||
RUN opam install . --deps-only | ||
# Install opam dependencies | ||
COPY --chown=opam --link ocamlorg.opam . | ||
RUN --mount=type=cache,target=/home/opam/.opam/download-cache,sharing=locked,uid=1000,gid=1000 \ | ||
opam install . --deps-only | ||
|
||
# Build project | ||
COPY --chown=opam:opam . . | ||
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_REPO_PATH opam-repository | ||
ENV OCAMLORG_PKG_STATE_PATH package.state | ||
RUN cd ~/opam-repository && git checkout master && opam update | ||
ENV OCAMLORG_REPO_PATH=opam-repository | ||
ENV OCAMLORG_PKG_STATE_PATH=package.state | ||
RUN touch package.state && ./init-cache package.state | ||
|
||
FROM alpine:3.20 as run | ||
FROM alpine:3.20 AS run | ||
|
||
RUN apk update && apk add --update libev gmp git | ||
RUN apk add --no-cache \ | ||
git \ | ||
gmp \ | ||
libev | ||
|
||
RUN chmod -R 755 /var | ||
COPY --from=build --link /home/opam/package.state /var/package.state | ||
COPY --from=build --link /home/opam/opam-repository /var/opam-repository | ||
COPY --from=build --link /home/opam/_build/default/src/ocamlorg_web/bin/main.exe /bin/server | ||
|
||
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 --link playground/asset playground/asset | ||
|
||
COPY playground/asset playground/asset | ||
|
||
RUN git clone https://github.com/ocaml-web/html-compiler-manuals /manual | ||
ADD --keep-git-dir --link https://github.com/ocaml-web/html-compiler-manuals /manual | ||
|
||
RUN git config --global --add safe.directory /var/opam-repository | ||
|
||
ENV OCAMLORG_REPO_PATH /var/opam-repository/ | ||
ENV OCAMLORG_MANUAL_PATH /manual | ||
ENV OCAMLORG_PKG_STATE_PATH /var/package.state | ||
ENV DREAM_VERBOSITY info | ||
ENV OCAMLORG_HTTP_PORT 8080 | ||
ENV OCAMLORG_REPO_PATH=/var/opam-repository/ | ||
ENV OCAMLORG_MANUAL_PATH=/manual | ||
ENV OCAMLORG_PKG_STATE_PATH=/var/package.state | ||
ENV DREAM_VERBOSITY=info | ||
ENV OCAMLORG_HTTP_PORT=8080 | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT /bin/server | ||
ENTRYPOINT ["/bin/server"] |