- Add complete pytest testing framework with conftest.py and test files - Add performance monitoring and benchmarking capabilities - Add plugin system with ccache plugin example - Add comprehensive documentation (API, deployment, testing, etc.) - Add Docker API wrapper for service deployment - Add advanced configuration examples - Remove old wget package file - Update core modules with enhanced functionality
89 lines
2.4 KiB
Text
89 lines
2.4 KiB
Text
FROM python:3.11-slim
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
curl \
|
|
schroot \
|
|
debootstrap \
|
|
sbuild \
|
|
sudo \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy deb-mock source code
|
|
COPY . .
|
|
|
|
# Install deb-mock in development mode
|
|
RUN pip install -e .
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/configs /app/work /app/cache /app/logs
|
|
|
|
# Create a simple API wrapper script
|
|
RUN echo '#!/usr/bin/env python3\n\
|
|
import os\n\
|
|
import subprocess\n\
|
|
import json\n\
|
|
from flask import Flask, request, jsonify\n\
|
|
\n\
|
|
app = Flask(__name__)\n\
|
|
\n\
|
|
@app.route("/health")\n\
|
|
def health():\n\
|
|
return jsonify({"status": "healthy", "service": "deb-mock-api"})\n\
|
|
\n\
|
|
@app.route("/api/v1/build", methods=["POST"])\n\
|
|
def build_package():\n\
|
|
try:\n\
|
|
data = request.get_json()\n\
|
|
package_name = data.get("package_name")\n\
|
|
architecture = data.get("architecture", "amd64")\n\
|
|
config_file = data.get("config_file", "config-advanced.yaml")\n\
|
|
\n\
|
|
# Execute deb-mock build command\n\
|
|
cmd = ["deb-mock", "-c", config_file, "build", package_name]\n\
|
|
result = subprocess.run(cmd, capture_output=True, text=True, cwd="/app")\n\
|
|
\n\
|
|
if result.returncode == 0:\n\
|
|
return jsonify({\n\
|
|
"status": "success",\n\
|
|
"package": package_name,\n\
|
|
"architecture": architecture,\n\
|
|
"output": result.stdout\n\
|
|
}), 200\n\
|
|
else:\n\
|
|
return jsonify({\n\
|
|
"status": "error",\n\
|
|
"package": package_name,\n\
|
|
"error": result.stderr\n\
|
|
}), 400\n\
|
|
except Exception as e:\n\
|
|
return jsonify({"status": "error", "error": str(e)}), 500\n\
|
|
\n\
|
|
@app.route("/api/v1/status", methods=["GET"])\n\
|
|
def status():\n\
|
|
return jsonify({\n\
|
|
"status": "running",\n\
|
|
"service": "deb-mock-api",\n\
|
|
"version": "1.0.0"\n\
|
|
})\n\
|
|
\n\
|
|
if __name__ == "__main__":\n\
|
|
port = int(os.environ.get("MOCK_API_PORT", 8081))\n\
|
|
app.run(host="0.0.0.0", port=port, debug=False)\n\
|
|
' > /app/api_server.py
|
|
|
|
# Make the API server executable
|
|
RUN chmod +x /app/api_server.py
|
|
|
|
# Expose the API port
|
|
EXPOSE 8081
|
|
|
|
# Start the API server
|
|
CMD ["python3", "/app/api_server.py"]
|