Finished Dockerfile

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-13 21:39:13 +02:00
parent 95cbce93f0
commit 294d402990
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E

View File

@ -1,54 +1,52 @@
FROM archlinux:latest FROM archlinux:latest
# 1) Update system and install build tools + Go for AUR package builds # 1) Update system and install build/runtime deps
RUN pacman -Syu --noconfirm \ RUN pacman -Syu --noconfirm \
base-devel \ base-devel \
git \ git \
sudo \
python \ python \
python-pip \ python-pip \
python-setuptools \
alsa-lib \
go \ go \
&& pacman -Scc --noconfirm && pacman -Scc --noconfirm
# 2) Create a non-root user for building AUR packages # 2) Stub out systemctl & yay so post-install hooks and AUR calls never fail
RUN useradd -m builder RUN printf '#!/bin/sh\nexit 0\n' > /usr/bin/systemctl \
&& chmod +x /usr/bin/systemctl \
&& printf '#!/bin/sh\nexit 0\n' > /usr/bin/yay \
&& chmod +x /usr/bin/yay
# 3) Clone & build yay as the unprivileged 'builder' user # 3) Build & install python-simpleaudio from AUR manually (as non-root)
USER builder RUN useradd -m builder \
WORKDIR /home/builder && su builder -c "git clone https://aur.archlinux.org/python-simpleaudio.git /home/builder/psa && \
RUN git clone https://aur.archlinux.org/yay.git \ cd /home/builder/psa && \
&& cd yay \ makepkg --noconfirm --skippgpcheck" \
&& makepkg --noconfirm --skippgpcheck && pacman -U --noconfirm /home/builder/psa/*.pkg.tar.zst \
&& rm -rf /home/builder/psa
# 4) Switch back to root to install the built yay package system-wide # 4) Clone Kevins Package Manager and create its venv
USER root ENV PKGMGR_REPO=/opt/package-manager \
RUN pacman -U --noconfirm /home/builder/yay/yay-*.pkg.tar.zst \ PKGMGR_VENV=/root/.venvs/pkgmgr
&& rm -rf /home/builder/yay
# 5) Define where our pkgmgr virtualenv and repo will live RUN git clone https://github.com/kevinveenbirkenbach/package-manager.git $PKGMGR_REPO \
ENV PKGMGR_VENV=/root/.venvs/pkgmgr && python -m venv $PKGMGR_VENV \
ENV PKGMGR_REPO=/opt/package-manager
# 6) Clone the package-manager sources
RUN git clone https://github.com/kevinveenbirkenbach/package-manager.git $PKGMGR_REPO
# 7) Create the venv and install its Python requirements there
RUN python -m venv $PKGMGR_VENV \
&& $PKGMGR_VENV/bin/pip install --upgrade pip \ && $PKGMGR_VENV/bin/pip install --upgrade pip \
&& $PKGMGR_VENV/bin/pip install --no-cache-dir -r $PKGMGR_REPO/requirements.txt # install pkgmgrs own deps + the ansible Python library so cymais import yaml & ansible.plugins.lookup work
&& $PKGMGR_VENV/bin/pip install --no-cache-dir -r $PKGMGR_REPO/requirements.txt ansible \
# 8) Write a tiny wrapper so `pkgmgr` always runs inside that venv # drop a thin wrapper so `pkgmgr` always runs inside that venv
RUN printf '#!/bin/sh\n' > /usr/local/bin/pkgmgr \ && printf '#!/bin/sh\n. %s/bin/activate\nexec python %s/main.py "$@"\n' \
&& printf '. %s/bin/activate\n' "$PKGMGR_VENV" >> /usr/local/bin/pkgmgr \ "$PKGMGR_VENV" "$PKGMGR_REPO" > /usr/local/bin/pkgmgr \
&& printf 'exec python %s/main.py "$@"\n' "$PKGMGR_REPO" >> /usr/local/bin/pkgmgr \
&& chmod +x /usr/local/bin/pkgmgr && chmod +x /usr/local/bin/pkgmgr
# 9) Ensure the venvs bin is first on PATH # 5) Ensure pkgmgr venv bin and user-local bin are on PATH
ENV PATH="$PKGMGR_VENV/bin:${PATH}" ENV PATH="$PKGMGR_VENV/bin:/root/.local/bin:${PATH}"
# 10) Use pkgmgr (inside the venv) to install CyMaIS, allowing AUR dependencies via yay # 6) Install CyMaIS (using HTTPS cloning mode)
RUN pkgmgr install cymais --clone-mode https RUN pkgmgr install cymais --clone-mode https
# 11) Expose the cymais CLI as the containers entrypoint # 7) Symlink the cymais CLI into /usr/local/bin so ENTRYPOINT works
RUN ln -s /root/.local/bin/cymais /usr/local/bin/cymais
ENTRYPOINT ["cymais"] ENTRYPOINT ["cymais"]
CMD ["--help"] CMD ["--help"]