FROM manibase

RUN \
	useradd -p locked -m mani && \
	dnf install -q -y ca-certificates git gcc ccache make systemd-devel meson \
		pciutils-devel libusbx-devel libftdi-devel libjaylink-devel && \
	{ dnf install -q -y libgpiod-devel || true; } && \
	dnf clean -q -y all

RUN mkdir -p -m 1777 /ccache

ENV GIT_SSL_NO_VERIFY=1
USER mani

ARG ORIGIN=https://review.sourcearcade.org/flashprog.git
RUN \
	cd && \
	mkdir .ccache && chown mani:mani .ccache && \
	git clone ${ORIGIN} flashprog

ARG IDENT=mani
ARG CCACHE_MAX=32M
RUN \
	ccache --set-config cache_dir=/ccache/${IDENT} && \
	ccache --set-config max_size=${CCACHE_MAX}

ENV DEVSHELL /bin/bash
COPY mani-wrapper.sh /home/mani/
ENTRYPOINT ["/bin/sh", "/home/mani/mani-wrapper.sh"]
