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

ARG OCAML_VERSION=4.10.0

Louis Gesbert's avatar
Louis Gesbert committed
5
RUN apk add gcc g++ make coreutils
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-alpha2
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
Louis Gesbert's avatar
Louis Gesbert committed
36

Louis Gesbert's avatar
Louis Gesbert committed
37
RUN touch /tmp/foo
Louis Gesbert's avatar
Louis Gesbert committed
38
RUN ["/usr/local/bin/opam", "init", "-a", "--bare", "--disable-sandboxing"]