Dockerfile 1.28 KB
Newer Older
Louis Gesbert's avatar
Louis Gesbert committed
1 2
FROM alpine:3.11 as compilation

3
ARG OCAML_VERSION=4.12.0
Louis Gesbert's avatar
Louis Gesbert committed
4

5
RUN apk add gcc g++ make coreutils openssl
Louis Gesbert's avatar
Louis Gesbert committed
6 7
ADD https://github.com/ocaml/ocaml/archive/${OCAML_VERSION}.tar.gz /src/ocaml.tar.gz
WORKDIR /src/ocaml
8
RUN tar xzf ../ocaml.tar.gz --strip-components=1 && ./configure && make world.opt && make install && rm -rf /src/ocaml
Louis Gesbert's avatar
Louis Gesbert committed
9

10
# ARG OPAM_VERSION=2.1.0-beta4
Louis Gesbert's avatar
Louis Gesbert committed
11

12 13
# ADD https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}/opam-full-${OPAM_VERSION}.tar.gz /src/opam.tar.gz
ADD https://github.com/ocaml/opam/archive/refs/heads/master.tar.gz /src/opam.tar.gz
Louis Gesbert's avatar
Louis Gesbert committed
14
WORKDIR /src/opam
15
RUN tar xzf ../opam.tar.gz --strip-components=1 && ./configure && make lib-ext && make && make install && rm -rf /src/opam
Louis Gesbert's avatar
Louis Gesbert committed
16 17 18 19 20


FROM alpine:3.11 as target
LABEL Description="Minimal OCaml + opam Alpine container" Vendor="OCamlPro"

21
RUN apk add gcc libc-dev make curl git sudo patch rsync m4
Louis Gesbert's avatar
Louis Gesbert committed
22 23 24
COPY --from=compilation /usr/local /usr/local

RUN addgroup -S ocaml && adduser -S ocaml -G ocaml -s /bin/sh
Louis Gesbert's avatar
Louis Gesbert committed
25
RUN echo 'ocaml ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
Louis Gesbert's avatar
Louis Gesbert committed
26 27
USER ocaml
WORKDIR /home/ocaml
Louis Gesbert's avatar
Louis Gesbert committed
28
ENV OPAMYES 1
29
ENV OPAMDEPEXTYES 1
30
ENV OPAMCONFIRMLEVEL unsafe-yes
Louis Gesbert's avatar
Louis Gesbert committed
31
ENV OPAMROOT /home/ocaml/.opam
Louis Gesbert's avatar
Louis Gesbert committed
32

33 34
ARG LAST_REPO_UPDATE=0
RUN echo "LAST_REPO_UPDATE=${LAST_REPO_UPDATE}"
Louis Gesbert's avatar
Louis Gesbert committed
35
RUN ["/usr/local/bin/opam", "init", "-a", "--bare", "--disable-sandboxing"]