Dockerfile 1.19 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-rc2
Louis Gesbert's avatar
Louis Gesbert committed
11

12
ADD https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}/opam-full-${OPAM_VERSION}.tar.gz /src/opam.tar.gz
Louis Gesbert's avatar
Louis Gesbert committed
13
WORKDIR /src/opam
14
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
15 16 17 18 19


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

20
RUN apk add gcc libc-dev make curl git sudo patch rsync m4
Louis Gesbert's avatar
Louis Gesbert committed
21 22 23
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
24
RUN echo 'ocaml ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
Louis Gesbert's avatar
Louis Gesbert committed
25 26
USER ocaml
WORKDIR /home/ocaml
Louis Gesbert's avatar
Louis Gesbert committed
27
ENV OPAMYES 1
28
ENV OPAMDEPEXTYES 1
29
ENV OPAMCONFIRMLEVEL unsafe-yes
Louis Gesbert's avatar
Louis Gesbert committed
30
ENV OPAMROOT /home/ocaml/.opam
Louis Gesbert's avatar
Louis Gesbert committed
31

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