Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (45 loc) · 2.2 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (45 loc) · 2.2 KB
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
# Plain Alpine instead of asemio/mountain-caravan, which is published for amd64 only.
# This lets the same file build natively on amd64 and arm64 hosts.
# The toolchain setup copies mountain-caravan 2.4.0: Alpine 3.20 and an opam switch with OCaml 5.1.1+options.
# Stay on Alpine 3.20: opam-repository marks core_unix v0.17 as unavailable on Alpine 3.21 and newer.
FROM alpine:3.20
# Keep the package index from `apk update` in the image: opam reads it to check system packages (depexts).
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
bash build-base ca-certificates cmake curl git libev-dev linux-headers m4 make \
npm opam openssl perl pkgconfig sudo tar unzip xz \
&& adduser -D opam \
&& echo 'opam ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER opam
SHELL ["/bin/bash", "-c"]
RUN opam init -y --bare --disable-sandboxing -a \
&& opam switch create 5.1.1+options --packages=ocaml-variants.5.1.1+options,ocaml-option-flambda
WORKDIR /app
COPY strings.opam .
# The `static` profile is `release` plus a fully static link (src/cli/link_flags.linux.static.dune).
# The binary then runs on any Linux distro of the same arch: it needs no musl loader and no shared libraries.
ENV DUNE_PROFILE=static
RUN opam update \
&& OPAMYES=1 opam install . --deps-only
RUN echo '=== Installing QuickJS ===' \
&& curl https://bellard.org/quickjs/quickjs-2021-03-27.tar.xz > quickjs.tar.xz \
&& tar xvf quickjs.tar.xz && rm quickjs.tar.xz \
&& mv quickjs-2021-03-27 quickjs \
&& cd quickjs && make && cd -
RUN echo '=== Installing Flow ===' \
&& git clone --branch v0.183.1 --depth 1 https://github.com/facebook/flow.git flow
RUN echo '=== Installing JS dependencies ===' \
&& npm install --no-save typescript@6 browserify pug-lexer pug-parser pug-walk
COPY src src
COPY dune dune
COPY dune-project dune-project
RUN sudo chown -R opam /app \
&& ln -s "$(pwd)/flow/src/parser" src/flow_parser \
&& ln -s "$(pwd)/flow/src/third-party/sedlex" src/sedlex \
&& ln -s "$(pwd)/flow/src/hack_forked/utils/collections" src/collections
RUN echo '=== Building ===' \
&& opam exec -- dune build src/cli/strings.exe \
&& cp /app/_build/default/src/cli/strings.exe . \
&& chmod 755 strings.exe \
&& strip strings.exe