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

Louis Gesbert's avatar
Louis Gesbert committed
3
ARG OCAML_VERSION=4.11.1
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

Louis Gesbert's avatar
Louis Gesbert committed
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
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
Louis Gesbert's avatar
Louis Gesbert committed
29

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