Files
PSProxmoxVE/tests/Dockerfile.test
T
Clint Branham 9817d30a11 feat(ci): multi-node PVE provisioning and Docker-based shared storage
Provision two PVE nodes per version (a/b) for future cluster testing,
plus Docker-based iSCSI target and NFS server for shared storage tests.

Multi-node changes:
- Each PVE version gets two nodes: 9a/9b and 8a/8b (4 VMs total)
- Parameterized answer.toml FQDN for unique hostnames per node
- Per-node auto-install ISOs with unique answer files
- Node name discovered from FQDN and included in test config
- API token creation handles pre-existing tokens (delete + recreate)
- New test env vars: PVETEST_HOST_B, PVETEST_APITOKEN_B
- Removed preflight cleanup from provision (use explicit cleanup instead)

Docker storage services:
- New docker-compose.storage.yml with iSCSI (tgt) and NFS containers
- Host networking so PVE nodes can reach storage services
- Docker socket mounted into dev-infra container for host Docker access
- Docker CLI added to dev-infra Dockerfile stage
- New test env vars: PVETEST_STORAGE_VM_IP, PVETEST_ISCSI_IQN, PVETEST_NFS_EXPORT

Other fixes:
- first-boot.sh installs open-iscsi on PVE nodes
- preflight-cleanup.sh handles empty ISO filename gracefully
- TMPDIR set to work dir to avoid /tmp overflow during ISO uploads

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 13:34:15 -05:00

70 lines
3.3 KiB
Docker

# PSProxmoxVE development and integration testing container
#
# Two targets:
# dev - .NET SDK + PowerShell + Pester (build & test, works on ARM/x86)
# dev-infra - Adds Terraform + PVE provisioning tools (x86 only)
#
# Usage:
# # For build + test (works on Mac M-series):
# docker compose -f tests/docker-compose.test.yml up -d
#
# # For full CI flow including provisioning (x86 only):
# docker compose -f tests/docker-compose.test.yml --profile infra up -d
# ── Base: .NET SDK + PowerShell + Pester ────────────────────────────
FROM mcr.microsoft.com/dotnet/sdk:10.0-noble AS dev
ENV DEBIAN_FRONTEND=noninteractive
# Install base packages
RUN apt-get update && apt-get install -y --no-install-recommends \
curl jq openssh-client ca-certificates apt-transport-https gnupg \
&& rm -rf /var/lib/apt/lists/*
# Install PowerShell: APT package on amd64, dotnet global tool on arm64.
# The Microsoft APT repo does not publish arm64 packages for PowerShell.
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
| gpg --dearmor -o /usr/share/keyrings/microsoft-archive-keyring.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] \
https://packages.microsoft.com/ubuntu/24.04/prod noble main" \
> /etc/apt/sources.list.d/microsoft-prod.list \
&& apt-get update && apt-get install -y --no-install-recommends powershell \
&& rm -rf /var/lib/apt/lists/*; \
else \
dotnet tool install --global PowerShell \
&& ln -s /root/.dotnet/tools/pwsh /usr/local/bin/pwsh; \
fi
# Install Pester and prepare module directory
RUN pwsh -NoProfile -Command \
'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; \
Install-Module -Name Pester -MinimumVersion 5.0 -Scope AllUsers -Force' \
&& mkdir -p /usr/local/share/powershell/Modules/PSProxmoxVE
WORKDIR /repo
CMD ["pwsh", "-NoProfile"]
# ── Full: adds Terraform + PVE provisioning tools (x86 only) ───────
FROM dev AS dev-infra
RUN apt-get update && apt-get install -y --no-install-recommends \
dosfstools mtools sshpass python3 xorriso gnupg \
&& curl -fsSL https://apt.releases.hashicorp.com/gpg \
| gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com noble main" \
> /etc/apt/sources.list.d/hashicorp.list \
&& curl -fsSL https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg \
-o /usr/share/keyrings/proxmox-release-bookworm.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/proxmox-release-bookworm.gpg] \
http://download.proxmox.com/debian/pve bookworm pve-no-subscription" \
> /etc/apt/sources.list.d/proxmox-pve.list \
&& apt-get update && apt-get install -y --no-install-recommends \
terraform proxmox-auto-install-assistant qemu-utils \
&& rm -rf /var/lib/apt/lists/*
# Install Docker CLI (for managing storage containers on the host via mounted socket)
RUN curl -fsSL https://get.docker.com | sh 2>/dev/null \
&& rm -rf /var/lib/apt/lists/*