# At the time of writing, Docker Hub was down. AWS's limits are also much more lenient than Docker Hub.
FROM public.ecr.aws/docker/library/debian:

RUN apt-get update && \
    apt-get -y upgrade && \
    apt-get -y dist-upgrade && \
    apt-get -y install git build-essential sudo vim

RUN sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g'
RUN useradd -G sudo -m user

WORKDIR /
RUN mkdir lbmk
RUN git clone https://codeberg.org/libreboot/lbmk.git lbmk

# Required to bypass lbmk apt w/o -y
USER root
RUN echo 'APT::Get::Assume-Yes "true";\n\
APT::Get::force-yes "true";\n'\
>> /etc/apt/apt.conf.d/90-force-yes

WORKDIR lbmk
RUN sudo ./mk dependencies debian
USER user
RUN chown user:sudo -R /lbmka

# Required by lbmk (for later build)
RUN git config --global user.name "John Doe" && \
    git config --global user.email johndoe@example.com

# NOTE: for multi-threaded builds, run 'export XBMK_THREADS=$(nproc)'
