Dockerfile 1.11 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 8 9 10 11 12
ADD https://github.com/ocaml/ocaml/archive/${OCAML_VERSION}.tar.gz /src/ocaml.tar.gz
WORKDIR /src/ocaml
RUN tar xzf ../ocaml.tar.gz --strip-components=1
RUN ./configure
RUN make world.opt
RUN make install

Louis Gesbert's avatar
Louis Gesbert committed
13
ARG OPAM_VERSION=2.1.0-beta2
Louis Gesbert's avatar
Louis Gesbert committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27

ADD https://github.com/ocaml/opam/releases/download/${OPAM_VERSION}/opam-full-${OPAM_VERSION}.tar.gz /src/opam.tar.gz
WORKDIR /src/opam
RUN tar xzf ../opam.tar.gz --strip-components=1
RUN ./configure
RUN make lib-ext
RUN make
RUN make install

RUN rm -rf /src

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

Louis Gesbert's avatar
Louis Gesbert committed
28
RUN apk add gcc libc-dev make curl git sudo patch
Louis Gesbert's avatar
Louis Gesbert committed
29 30 31
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
32
RUN echo 'ocaml ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
Louis Gesbert's avatar
Louis Gesbert committed
33 34
USER ocaml
WORKDIR /home/ocaml
Louis Gesbert's avatar
Louis Gesbert committed
35
ENV OPAMYES 1
36
ENV OPAMDEPEXTYES 1
Louis Gesbert's avatar
Louis Gesbert committed
37

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