FROM archlinux:latest AS builder
LABEL org.opencontainers.image.authors="Tiago de Paula Peixoto <tiago@skewed.de>"

RUN pacman -Sy
RUN pacman -S pacman-contrib --noconfirm --disable-download-timeout
RUN curl -s "https://archlinux.org/mirrorlist/?country=AT&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > /etc/pacman.d/mirrorlist

RUN pacman -Syu --noconfirm --disable-download-timeout
RUN pacman -S binutils make gcc fakeroot libtool --noconfirm --needed
RUN pacman -S expac yajl git --noconfirm --needed
RUN pacman -S sudo grep file --noconfirm --needed

# RUN pacman -S python-graph-tool --noconfirm --needed

RUN pacman -S sudo boost python python-scipy python-numpy python-zstandard \
              cgal cairomm-1.16 python-cairo sparsehash cairomm debugedit \
              autoconf-archive autoconf automake pkg-config gd lib32-gcc-libs bison \
              python-gobject \
              --noconfirm --needed

RUN pacman -S ccache emacs perf --noconfirm --needed

RUN pacman -S jupyter-notebook python-matplotlib --noconfirm --needed

RUN pacman -S texlive-meta --noconfirm --needed

ARG USER
ARG UID

RUN groupadd -g ${UID} ${USER}
RUN useradd -u ${UID} -g ${UID} -m ${USER}

RUN echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/user
RUN chmod -c 0440 /etc/sudoers.d/user
