FROM debian:unstable AS framac-base
ENV DEBIAN_FRONTEND=noninteractive
RUN useradd frama-c -m -u 9000 && \
    apt-get update && \
    apt-get install -y --no-install-recommends opam \
        autoconf \
        ca-certificates \
        git \
        graphviz \
        libcairo2-dev \
        libexpat1-dev \
        libgmp-dev \
        libgtk-3-dev \
        libgtksourceview-3.0-dev \
        pkg-config \
        wget \
        zlib1g-dev && \
    apt clean
COPY container/* /
RUN su frama-c -c /install_framac.sh

FROM framac-base AS framac
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get remove --purge -y \
        ca-certificates \
        git \
        graphviz \
        libcairo2-dev \
        libexpat1-dev \
        libgmp-dev \
        libgtk-3-dev \
        libgtksourceview-3.0-dev \
        zlib1g-dev \
        autoconf && \
    apt-get autoremove -y && \
    apt-get install --no-install-recommends -y \
        libgtk-3-0 \
        libgtksourceview-3.0-1 \
        dbus-user-session \
        libgdk-pixbuf-2.0-0 \
        libgtksourceview-3.0-1 \
        zlib1g \
        localepurge
RUN rm -rf /usr/share/man/??; rm -rf /usr/share/man/??_*
USER frama-c
ENV OPAMROOT=/home/frama-c/.opam
WORKDIR /data
ENTRYPOINT ["/entrypoint.sh"]
