# Docker >= 17.05.0-ce allows using build-time args (ARG) in FROM (#31352).
# https://github.com/moby/moby/releases/tag/v17.05.0-ce
ARG BASE_IMAGE=fedora
#FROM ${BASE_IMAGE}
FROM fedora:41-aarch64

# Test with non-root user.
ENV TEST_USER tester
ENV WORK_DIR "/work"

#RUN uname -a
#RUN echo -e "deltarpm=0\ninstall_weak_deps=0\ntsflags=nodocs" >> /etc/dnf/dnf.conf
# Disable modular repositories to save a running time of "dnf update"
# if they exists.
#RUN ls /etc/yum.repos.d/*.repo
RUN sed -i '/^enabled=1$/ s/1/0/' /etc/yum.repos.d/*-modular.repo || true
# RUN dnf -y update
RUN dnf -y --allowerasing --repo fedora install \
  file gcc git make redhat-rpm-config sudo \
  automake autoconf libtool perl-Text-Diff pkgconf-pkg-config strace gdb
#RUN dnf -y --repo fedora install m4

# Create test user and the environment
RUN useradd "${TEST_USER}"
# Enable sudo without password for convenience.
RUN echo "${TEST_USER} ALL = NOPASSWD: ALL" >> /etc/sudoers

WORKDIR "${WORK_DIR}"
COPY . .
RUN chown -R "${TEST_USER}:${TEST_USER}" "${WORK_DIR}"
USER "${TEST_USER}"

RUN ./configure --host=aarch64-linux-gnu --disable-shared --enable-debug
RUN make
