2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
# Base image selector — overridden by Makefile
|
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
ARG BASE_IMAGE=archlinux:latest
|
|
|
|
|
FROM ${BASE_IMAGE}
|
2025-07-11 07:19:44 +02:00
|
|
|
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-08 15:08:42 +01:00
|
|
|
# System base + conditional package tool installation
|
|
|
|
|
#
|
|
|
|
|
# Important:
|
|
|
|
|
# - We do NOT install Nix directly here via curl.
|
|
|
|
|
# - Nix is installed/initialized by init-nix.sh, which is invoked
|
|
|
|
|
# from the system packaging hooks (Arch .install, Debian postinst,
|
|
|
|
|
# RPM %post).
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
RUN set -e; \
|
|
|
|
|
if [ -f /etc/os-release ]; then . /etc/os-release; else echo "No /etc/os-release found" && exit 1; fi; \
|
|
|
|
|
echo "Detected base image: ${ID:-unknown} (like: ${ID_LIKE:-})"; \
|
|
|
|
|
\
|
|
|
|
|
if [ "$ID" = "arch" ]; then \
|
|
|
|
|
pacman -Syu --noconfirm && \
|
|
|
|
|
pacman -S --noconfirm --needed \
|
|
|
|
|
base-devel \
|
|
|
|
|
git \
|
2025-12-08 01:40:36 +01:00
|
|
|
rsync \
|
2025-12-08 15:08:42 +01:00
|
|
|
curl \
|
|
|
|
|
ca-certificates \
|
|
|
|
|
xz && \
|
2025-12-08 00:24:22 +01:00
|
|
|
pacman -Scc --noconfirm; \
|
|
|
|
|
elif [ "$ID" = "debian" ]; then \
|
|
|
|
|
apt-get update && \
|
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
2025-12-08 15:08:42 +01:00
|
|
|
build-essential \
|
|
|
|
|
debhelper \
|
|
|
|
|
dpkg-dev \
|
2025-12-08 00:24:22 +01:00
|
|
|
git \
|
|
|
|
|
rsync \
|
|
|
|
|
bash \
|
2025-12-08 15:08:42 +01:00
|
|
|
curl \
|
|
|
|
|
ca-certificates \
|
2025-12-08 00:24:22 +01:00
|
|
|
xz-utils && \
|
2025-12-08 15:08:42 +01:00
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
2025-12-08 00:24:22 +01:00
|
|
|
elif [ "$ID" = "ubuntu" ]; then \
|
|
|
|
|
apt-get update && \
|
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
2025-12-08 15:08:42 +01:00
|
|
|
build-essential \
|
|
|
|
|
debhelper \
|
|
|
|
|
dpkg-dev \
|
2025-12-08 00:24:22 +01:00
|
|
|
git \
|
|
|
|
|
tzdata \
|
|
|
|
|
lsb-release \
|
|
|
|
|
rsync \
|
|
|
|
|
bash \
|
2025-12-08 15:08:42 +01:00
|
|
|
curl \
|
|
|
|
|
ca-certificates \
|
2025-12-08 00:24:22 +01:00
|
|
|
xz-utils && \
|
2025-12-08 15:08:42 +01:00
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
2025-12-08 00:24:22 +01:00
|
|
|
elif [ "$ID" = "fedora" ]; then \
|
|
|
|
|
dnf -y update && \
|
|
|
|
|
dnf -y install \
|
|
|
|
|
git \
|
|
|
|
|
rsync \
|
2025-12-08 15:08:42 +01:00
|
|
|
rpm-build \
|
|
|
|
|
make \
|
|
|
|
|
gcc \
|
2025-12-08 00:24:22 +01:00
|
|
|
bash \
|
2025-12-08 15:08:42 +01:00
|
|
|
curl \
|
|
|
|
|
ca-certificates \
|
2025-12-08 00:24:22 +01:00
|
|
|
xz && \
|
2025-12-08 15:08:42 +01:00
|
|
|
dnf clean all; \
|
2025-12-08 00:24:22 +01:00
|
|
|
elif [ "$ID" = "centos" ]; then \
|
|
|
|
|
dnf -y update && \
|
|
|
|
|
dnf -y install \
|
|
|
|
|
git \
|
|
|
|
|
rsync \
|
2025-12-08 15:08:42 +01:00
|
|
|
rpm-build \
|
|
|
|
|
make \
|
|
|
|
|
gcc \
|
2025-12-08 00:24:22 +01:00
|
|
|
bash \
|
2025-12-08 15:08:42 +01:00
|
|
|
curl-minimal \
|
|
|
|
|
ca-certificates \
|
2025-12-08 00:24:22 +01:00
|
|
|
xz && \
|
2025-12-08 15:08:42 +01:00
|
|
|
dnf clean all; \
|
2025-12-08 00:24:22 +01:00
|
|
|
else \
|
|
|
|
|
echo "Unsupported base image: ${ID}" && exit 1; \
|
|
|
|
|
fi
|
2025-07-11 07:19:44 +02:00
|
|
|
|
2025-12-08 01:40:36 +01:00
|
|
|
# ------------------------------------------------------------
|
|
|
|
|
# Nix environment defaults
|
2025-12-08 15:08:42 +01:00
|
|
|
#
|
|
|
|
|
# Nix itself is installed by your system packages (via init-nix.sh).
|
|
|
|
|
# Here we only define default configuration options.
|
2025-12-08 01:40:36 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-07 20:58:49 +01:00
|
|
|
ENV NIX_CONFIG="experimental-features = nix-command flakes"
|
|
|
|
|
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-08 15:08:42 +01:00
|
|
|
# Unprivileged user for Arch package build (makepkg)
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-08 15:08:42 +01:00
|
|
|
RUN useradd -m builder || true
|
2025-07-11 07:19:44 +02:00
|
|
|
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-08 15:08:42 +01:00
|
|
|
# Build and install distro-native package-manager package
|
|
|
|
|
#
|
|
|
|
|
# - Arch: PKGBUILD -> pacman -U
|
|
|
|
|
# - Debian: debhelper -> dpkg-buildpackage -> apt install ./package-manager_*.deb
|
|
|
|
|
# - Ubuntu: same as Debian
|
|
|
|
|
# - Fedora: rpmbuild -> dnf/dnf5/yum install package-manager-*.rpm
|
|
|
|
|
# - CentOS: rpmbuild -> dnf/yum install package-manager-*.rpm
|
|
|
|
|
#
|
|
|
|
|
# Nix is NOT manually installed here; it is handled by init-nix.sh.
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-07 21:43:38 +01:00
|
|
|
WORKDIR /build
|
2025-12-07 20:54:04 +01:00
|
|
|
COPY . .
|
2025-12-03 16:09:42 +01:00
|
|
|
|
2025-12-08 00:24:22 +01:00
|
|
|
RUN set -e; \
|
2025-12-08 15:08:42 +01:00
|
|
|
. /etc/os-release; \
|
2025-12-08 00:24:22 +01:00
|
|
|
if [ "$ID" = "arch" ]; then \
|
2025-12-08 15:08:42 +01:00
|
|
|
echo 'Building Arch package (makepkg --nodeps)...'; \
|
|
|
|
|
chown -R builder:builder /build; \
|
|
|
|
|
su builder -c "cd /build && rm -f package-manager-*.pkg.tar.* && makepkg --noconfirm --clean --nodeps"; \
|
|
|
|
|
\
|
|
|
|
|
echo 'Installing generated Arch package...'; \
|
2025-12-08 00:24:22 +01:00
|
|
|
pacman -U --noconfirm package-manager-*.pkg.tar.*; \
|
2025-12-08 15:08:42 +01:00
|
|
|
elif [ "$ID" = "debian" ] || [ "$ID" = "ubuntu" ]; then \
|
|
|
|
|
echo 'Building Debian/Ubuntu package...'; \
|
|
|
|
|
dpkg-buildpackage -us -uc -b; \
|
|
|
|
|
\
|
|
|
|
|
echo 'Installing generated DEB package...'; \
|
|
|
|
|
apt-get update && \
|
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y ./../package-manager_*.deb && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
|
|
|
elif [ "$ID" = "fedora" ] || [ "$ID" = "centos" ]; then \
|
|
|
|
|
echo 'Setting up rpmbuild dirs...'; \
|
|
|
|
|
mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}; \
|
|
|
|
|
\
|
|
|
|
|
echo "Extracting version from package-manager.spec..."; \
|
|
|
|
|
version=$(grep -E '^Version:' /build/package-manager.spec | awk '{print $2}'); \
|
|
|
|
|
if [ -z "$version" ]; then echo 'ERROR: Version missing!' && exit 1; fi; \
|
|
|
|
|
srcdir="package-manager-${version}"; \
|
|
|
|
|
\
|
|
|
|
|
echo "Preparing source tree for RPM: $srcdir"; \
|
|
|
|
|
rm -rf "/tmp/$srcdir"; \
|
|
|
|
|
mkdir -p "/tmp/$srcdir"; \
|
|
|
|
|
cp -a /build/. "/tmp/$srcdir/"; \
|
|
|
|
|
\
|
|
|
|
|
echo "Creating source tarball: /root/rpmbuild/SOURCES/$srcdir.tar.gz"; \
|
|
|
|
|
tar czf "/root/rpmbuild/SOURCES/$srcdir.tar.gz" -C /tmp "$srcdir"; \
|
|
|
|
|
\
|
|
|
|
|
echo 'Copying SPEC...'; \
|
|
|
|
|
cp /build/package-manager.spec /root/rpmbuild/SPECS/; \
|
|
|
|
|
\
|
|
|
|
|
echo 'Running rpmbuild...'; \
|
|
|
|
|
cd /root/rpmbuild/SPECS && rpmbuild -bb package-manager.spec; \
|
|
|
|
|
\
|
2025-12-08 17:39:21 +01:00
|
|
|
echo 'Installing generated RPM (local, offline)...'; \
|
2025-12-08 15:08:42 +01:00
|
|
|
rpm_path=$(find /root/rpmbuild/RPMS -name "package-manager-*.rpm" | head -n1); \
|
|
|
|
|
if [ -z "$rpm_path" ]; then echo 'ERROR: RPM not found!' && exit 1; fi; \
|
|
|
|
|
\
|
|
|
|
|
if command -v dnf5 >/dev/null 2>&1; then \
|
2025-12-08 17:39:21 +01:00
|
|
|
echo 'Using dnf5 to install local RPM (no remote repos)...'; \
|
|
|
|
|
if ! dnf5 install -y --disablerepo='*' "$rpm_path"; then \
|
|
|
|
|
echo 'dnf5 failed, falling back to rpm -i --nodeps'; \
|
|
|
|
|
rpm -i --nodeps "$rpm_path"; \
|
|
|
|
|
fi; \
|
2025-12-08 15:08:42 +01:00
|
|
|
elif command -v dnf >/dev/null 2>&1; then \
|
2025-12-08 17:39:21 +01:00
|
|
|
echo 'Using dnf to install local RPM (no remote repos)...'; \
|
|
|
|
|
if ! dnf install -y --disablerepo='*' "$rpm_path"; then \
|
|
|
|
|
echo 'dnf failed, falling back to rpm -i --nodeps'; \
|
|
|
|
|
rpm -i --nodeps "$rpm_path"; \
|
|
|
|
|
fi; \
|
2025-12-08 15:08:42 +01:00
|
|
|
elif command -v yum >/dev/null 2>&1; then \
|
2025-12-08 17:39:21 +01:00
|
|
|
echo 'Using yum to install local RPM (no remote repos)...'; \
|
|
|
|
|
if ! yum localinstall -y --disablerepo='*' "$rpm_path"; then \
|
|
|
|
|
echo 'yum failed, falling back to rpm -i --nodeps'; \
|
|
|
|
|
rpm -i --nodeps "$rpm_path"; \
|
|
|
|
|
fi; \
|
2025-12-08 15:08:42 +01:00
|
|
|
else \
|
2025-12-08 17:39:21 +01:00
|
|
|
echo 'No dnf/dnf5/yum found, falling back to rpm -i --nodeps...'; \
|
|
|
|
|
rpm -i --nodeps "$rpm_path"; \
|
2025-12-08 15:08:42 +01:00
|
|
|
fi; \
|
|
|
|
|
\
|
|
|
|
|
rm -rf "/tmp/$srcdir"; \
|
2025-12-08 00:24:22 +01:00
|
|
|
else \
|
2025-12-08 15:08:42 +01:00
|
|
|
echo "Unsupported distro: ${ID}"; \
|
|
|
|
|
exit 1; \
|
2025-12-08 00:24:22 +01:00
|
|
|
fi; \
|
|
|
|
|
rm -rf /build
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------
|
2025-12-08 01:40:36 +01:00
|
|
|
# Runtime working directory and dev entrypoint
|
2025-12-08 00:24:22 +01:00
|
|
|
# ------------------------------------------------------------
|
2025-12-05 19:32:42 +01:00
|
|
|
WORKDIR /src
|
2025-07-11 07:19:44 +02:00
|
|
|
|
2025-12-07 21:43:38 +01:00
|
|
|
COPY scripts/docker-entry-dev.sh /usr/local/bin/docker-entry-dev.sh
|
|
|
|
|
RUN chmod +x /usr/local/bin/docker-entry-dev.sh
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["/usr/local/bin/docker-entry-dev.sh"]
|
2025-07-11 07:19:44 +02:00
|
|
|
CMD ["--help"]
|