Use podman instead of docker

This commit is contained in:
Bill Thiede 2025-12-04 16:51:02 -08:00
parent 492d06b0d6
commit 91d5db6453
2 changed files with 17 additions and 17 deletions

View File

@ -88,7 +88,7 @@ class Config:
@property
def docker_config(self) -> dict:
"""Get Docker configuration with defaults"""
"""Get Podman configuration with defaults"""
docker_config = self.config.get('docker', {})
return {
'build_cache_dir': docker_config.get('build_cache_dir', ''),
@ -574,13 +574,13 @@ class CargoAOCRunner:
@staticmethod
def _run_cargo_aoc_in_container(work_dir: Path, day: int, repo_root: Path, docker_config: dict) -> subprocess.CompletedProcess:
"""Run cargo aoc in a Docker container for security
"""Run cargo aoc in a Podman container for security
Args:
work_dir: Working directory (year directory) - can be absolute or relative
day: Day number to run
repo_root: Absolute path to repository root
docker_config: Docker configuration dictionary
docker_config: Podman configuration dictionary
Returns:
CompletedProcess with stdout, stderr, returncode
@ -617,9 +617,9 @@ class CargoAOCRunner:
registry_cache_dir = docker_config.get('registry_cache_dir', '')
try:
# Build Docker command
docker_cmd = [
'docker', 'run',
# Build Podman command
podman_cmd = [
'podman', 'run',
'--rm', # Remove container after execution
'--network=none', # No network access
'--memory', docker_config.get('memory', '2g'), # Limit memory
@ -636,14 +636,14 @@ class CargoAOCRunner:
# Use persistent registry cache
registry_cache_path = Path(registry_cache_dir).resolve()
registry_cache_path.mkdir(parents=True, exist_ok=True)
docker_cmd.extend(['-v', f'{registry_cache_path}:/root/.cargo/registry:rw'])
podman_cmd.extend(['-v', f'{registry_cache_path}:/root/.cargo/registry:rw'])
logger.info(f"Using persistent registry cache: {registry_cache_path}")
else:
# Use tmpfs for registry cache (cleared after each run)
docker_cmd.extend(['--tmpfs', '/root/.cargo/registry:rw,noexec,nosuid,size=100m'])
podman_cmd.extend(['--tmpfs', '/root/.cargo/registry:rw,noexec,nosuid,size=100m'])
# Add Docker image and command
docker_cmd.extend([
# Add Podman image and command
podman_cmd.extend([
docker_config.get('image', 'rust:latest'),
'cargo', 'aoc', '--day', str(day)
])
@ -653,7 +653,7 @@ class CargoAOCRunner:
env['CARGO_TARGET_DIR'] = '/build/target'
result = subprocess.run(
docker_cmd,
podman_cmd,
capture_output=True,
text=True,
timeout=300, # 5 minute timeout
@ -714,8 +714,8 @@ class CargoAOCRunner:
for day in days:
try:
logger.info(f"Running cargo aoc for {user} year {year} day {day} in {work_dir} (in Docker container)")
# Run cargo aoc in a Docker container for security
logger.info(f"Running cargo aoc for {user} year {year} day {day} in {work_dir} (in Podman container)")
# Run cargo aoc in a Podman container for security
# Use default docker_config if not provided
if docker_config is None:
docker_config = {
@ -737,7 +737,7 @@ class CargoAOCRunner:
with open(log_file, 'a', encoding='utf-8') as f:
f.write(f"\n{'='*80}\n")
f.write(f"[{timestamp}] {user} - Year {year} - Day {day}\n")
f.write(f"Command: cargo aoc --day {day} (in Docker container)\n")
f.write(f"Command: cargo aoc --day {day} (in Podman container)\n")
f.write(f"Working Directory: {work_dir}\n")
f.write(f"Return Code: {result.returncode}\n")
f.write(f"{'='*80}\n")
@ -2068,7 +2068,7 @@ class AOCSync:
# Create log file path in output directory
log_file = Path(self.config.output_dir) / 'cargo-aoc.log'
log_file.parent.mkdir(parents=True, exist_ok=True)
# Get Docker configuration
# Get Podman configuration
docker_config = self.config.docker_config
results = CargoAOCRunner.run_benchmarks(repo_path, year=year, user=user,
repo_url=repo_url, is_multi_year=is_multi_year,

View File

@ -13,7 +13,7 @@ rsync:
enabled: true
destination: "xinu.tv:/var/www/static/aoc/"
# Docker container configuration for running cargo aoc
# Podman container configuration for running cargo aoc
docker:
# Persistent directory for cargo build artifacts (speeds up rebuilds)
# If not specified, uses temporary directory that's cleaned up after each run
@ -27,7 +27,7 @@ docker:
memory: "2g" # Memory limit
cpus: "2" # CPU limit
# Docker image to use
# Podman image to use
image: "rust:latest"
# Repositories to monitor