AgentSkillsCN

devops-packaging-job

作业打包配置的脚手架搭建。关键词:打包、作业、DevOps、脚手架搭建。

SKILL.md
--- frontmatter
name: devops-packaging-job
description: "Scaffold job packaging configuration. Keywords: packaging, job, devops, scaffolding."

Scaffold: Job Packaging

This document is an entrypoint for job packaging scaffolding. The step-by-step flow is in /.system/skills/ssot/repo/scaffolding/devops-packaging-job/SKILL.md.


1. Purpose & Scope

Purpose: Generate packaging skeleton for deploying a module as a batch job (cron job, scheduled task, one-off execution).

Scope:

  • Creates job packaging configuration files
  • Sets up Dockerfile template optimized for batch execution
  • Configures job scripts
  • Records packaging decisions in workdocs

Out of scope:

  • Actual Docker image building
  • Job scheduler configuration (Kubernetes CronJob, etc.)
  • HTTP service packaging (see devops_packaging_service.md)
  • Deployment (see devops_deploy_job.md)

2. Inputs & Preconditions

Required Inputs

ParameterTypeDescription
job_namestringJob identifier (used in image tags)
module_idstringSource module being packaged
entrypointstringJob entrypoint script or command

Optional Inputs

ParameterTypeDefaultDescription
base_imagestringpython:3.11-slimDocker base image
schedulestring""Cron schedule expression (informational)
timeoutstring1hJob timeout
retry_policyobject{}Retry configuration
registrystring""Container registry URL

Preconditions

  1. Target module exists in /modules/<module_id>/
  2. Module has a runnable job entrypoint
  3. /ops/packaging/ directory exists
  4. Human has container registry credentials (if pushing images)

3. Step-by-Step Flow (AI + Human)

See /.system/skills/ssot/repo/scaffolding/devops-packaging-job/SKILL.md.


4. Tools & Scripts

ToolPurpose
scripts/devops/scaffold/devops_packaging_job.pyOrchestrator script
/ops/packaging/scripts/build.shGenerated build script

5. Outputs & Side Effects

Files Created

code
ops/packaging/jobs/<job_name>/
  Dockerfile          # Docker build configuration
  run.sh              # Job run script
  config.yaml         # Job configuration
  README.md           # Human-facing documentation

Dockerfile Template

dockerfile
# Auto-generated by devops_packaging_job scaffold
FROM python:3.11-slim

WORKDIR /app

# Install dependencies
COPY modules/<module_id>/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY modules/<module_id>/src/ ./src/

# Job entrypoint
ENTRYPOINT ["python", "-m", "<entrypoint>"]

Configuration File

yaml
job_name: <job_name>
module_id: <module_id>
entrypoint: <entrypoint>
base_image: python:3.11-slim
schedule: ""  # e.g., "0 2 * * *" for daily at 2am
timeout: 1h
retry_policy:
  max_retries: 3
  backoff: exponential
registry: ""

6. Safety & Rollback

Safety Measures

  • --dry-run always available for preview
  • Human approval required before execution
  • No actual Docker builds during scaffold
  • Credentials not stored in generated files

Rollback Procedure

If scaffold fails or needs reverting:

  1. Delete the packaging directory:
    bash
    rm -rf ops/packaging/jobs/<job_name>/
    

7. Next Steps After Scaffolding

  1. Review and customize generated Dockerfile
  2. Build image locally:
    bash
    cd ops/packaging/jobs/<job_name>
    docker build -t <job_name>:latest .
    
  3. Test job locally:
    bash
    docker run --rm <job_name>:latest
    
  4. Push to registry (requires credentials):
    bash
    docker push <registry>/<job_name>:latest
    
  5. Configure deployment/scheduling (see /.system/skills/ssot/repo/scaffolding/devops-deploy-job/SKILL.md)

8. Related Documents

  • /.system/skills/ssot/repo/scaffolding/devops-packaging-job/templates/packaging_template.md - Packaging knowledge template
  • /.system/skills/ssot/repo/scaffolding/devops-packaging-service/SKILL.md - Service packaging scaffold
  • /.system/skills/ssot/repo/scaffolding/devops-deploy-job/SKILL.md - Job deployment scaffold
  • /ops/packaging/AGENTS.md - Packaging strategy