Team Ai
Apppublic

jester1177/cloud-native-debug-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
task_5_ci_docker_integration.py312 linesDownload Raw Back to tasks
1"""Task 5: CI and Docker Build Integration — MEDIUM-HARD.2 3Agent debugs combined workflow + Docker build integration failures:4- Missing Buildx for multi-platform5- Docker login needs secrets in env block6- Build context path mismatch7- Cache configuration errors8- Missing Docker login before push9"""10 11 12 13from server.models import TaskDifficulty14from server.tasks.base import BaseTask15 16 17class CIDockerIntegrationTask(BaseTask):18    NAME = "CI and Docker Build Integration"19    DESCRIPTION = "Debug combined workflow and Docker build integration failures"20    DIFFICULTY = TaskDifficulty.MEDIUM21    AVAILABLE_SECRETS = ["DOCKER_USERNAME", "DOCKER_PASSWORD", "GITHUB_TOKEN"]22 23    SCENARIOS = [24        # Scenario 1: Missing Buildx setup for multi-platform build25        {26            "id": "missing_buildx_for_platforms",27            "files": [28                {29                    "path": ".github/workflows/build.yml",30                    "type": "workflow",31                    "content": (32                        "name: Multi-platform Build\n"33                        "on: push\n"34                        "\n"35                        "jobs:\n"36                        "  build:\n"37                        "    runs-on: ubuntu-latest\n"38                        "    steps:\n"39                        "      - uses: actions/checkout@v4\n"40                        "      - name: Build multi-platform\n"41                        "        uses: docker/build-push-action@v5\n"42                        "        with:\n"43                        "          context: .\n"44                        "          platforms: linux/amd64,linux/arm64\n"45                        "          push: false"46                    ),47                },48                {49                    "path": "Dockerfile",50                    "type": "dockerfile",51                    "content": (52                        "FROM python:3.11-slim\n"53                        "WORKDIR /app\n"54                        "COPY . .\n"55                        'CMD ["python", "app.py"]'56                    ),57                },58            ],59            "error": {60                "phase": "docker_build",61                "message": (62                    "ERROR: Multi-platform build is not supported for the docker driver. "63                    "Switch to a different driver, or turn on the containerd image store."64                ),65                "exit_code": 1,66                "failed_step": "Build multi-platform",67            },68            "expected_fixes": [69                {70                    "file": ".github/workflows/build.yml",71                    "type": "contains",72                    "expected": "docker/setup-buildx-action",73                    "hint": "Multi-platform builds require Docker Buildx setup step",74                }75            ],76        },77 78        # Scenario 2: Docker login + build but secrets not wired in env block79        {80            "id": "login_secrets_not_wired",81            "files": [82                {83                    "path": ".github/workflows/build.yml",84                    "type": "workflow",85                    "content": (86                        "name: Build and Push\n"87                        "on: push\n"88                        "\n"89                        "jobs:\n"90                        "  build:\n"91                        "    runs-on: ubuntu-latest\n"92                        "    steps:\n"93                        "      - uses: actions/checkout@v4\n"94                        "      - name: Login to DockerHub\n"95                        "        run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin\n"96                        "      - name: Build\n"97                        "        run: docker build -t myuser/app:latest .\n"98                        "      - name: Push\n"99                        "        run: docker push myuser/app:latest"100                    ),101                },102                {103                    "path": "Dockerfile",104                    "type": "dockerfile",105                    "content": (106                        "FROM node:18-alpine\n"107                        "WORKDIR /app\n"108                        "COPY package*.json ./\n"109                        "RUN npm ci\n"110                        "COPY . .\n"111                        "EXPOSE 3000\n"112                        'CMD ["npm", "start"]'113                    ),114                },115                {116                    "path": "package.json",117                    "type": "other",118                    "content": '{"name": "app", "scripts": {"start": "node server.js"}}',119                },120            ],121            "error": {122                "phase": "workflow_parse",123                "message": "Error: Cannot perform an interactive login from a non TTY device",124                "exit_code": 1,125                "failed_step": "Login to DockerHub",126            },127            "expected_fixes": [128                {129                    "file": ".github/workflows/build.yml",130                    "type": "contains",131                    "expected": "DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}",132                    "hint": "Secrets need to be mapped to env vars in the step", 133                },134                {135                    "file": ".github/workflows/build.yml",136                    "type": "contains",137                    "expected": "DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}",138                    "hint": "Both Docker credentials must be in the env block",139                },140            ],141        },142 143        # Scenario 3: Build context path wrong — using subdirectory but context is .144        {145            "id": "wrong_build_context",146            "files": [147                {148                    "path": ".github/workflows/build.yml",149                    "type": "workflow",150                    "content": (151                        "name: Build Backend\n"152                        "on: push\n"153                        "\n"154                        "jobs:\n"155                        "  build:\n"156                        "    runs-on: ubuntu-latest\n"157                        "    steps:\n"158                        "      - uses: actions/checkout@v4\n"159                        "      - name: Build backend\n"160                        "        uses: docker/build-push-action@v5\n"161                        "        with:\n"162                        "          context: ./backend\n"163                        "          file: ./Dockerfile\n"164                        "          push: false"165                    ),166                },167                {168                    "path": "Dockerfile",169                    "type": "dockerfile",170                    "content": (171                        "FROM python:3.11-slim\n"172                        "WORKDIR /app\n"173                        "COPY requirements.txt .\n"174                        "RUN pip install -r requirements.txt\n"175                        "COPY . .\n"176                        'CMD ["python", "app.py"]'177                    ),178                },179                {180                    "path": "requirements.txt",181                    "type": "requirements",182                    "content": "flask==2.3.0",183                },184            ],185            "error": {186                "phase": "docker_build",187                "message": (188                    "unable to prepare context: path \"./Dockerfile\" not found — "189                    "Dockerfile path does not match build context"190                ),191                "exit_code": 1,192                "failed_step": "Build backend",193            },194            "expected_fixes": [195                {196                    "file": ".github/workflows/build.yml",197                    "type": "contains",198                    "expected": "file: ./backend/Dockerfile",199                    "hint": "When context is ./backend, the Dockerfile path must be relative to repo root: ./backend/Dockerfile",200                }201            ],202        },203 204        # Scenario 4: Cache export without mode=max205        {206            "id": "cache_without_mode_max",207            "files": [208                {209                    "path": ".github/workflows/build.yml",210                    "type": "workflow",211                    "content": (212                        "name: Build with Cache\n"213                        "on: push\n"214                        "\n"215                        "jobs:\n"216                        "  build:\n"217                        "    runs-on: ubuntu-latest\n"218                        "    steps:\n"219                        "      - uses: actions/checkout@v4\n"220                        "      - name: Set up Docker Buildx\n"221                        "        uses: docker/setup-buildx-action@v3\n"222                        "      - name: Build\n"223                        "        uses: docker/build-push-action@v5\n"224                        "        with:\n"225                        "          context: .\n"226                        "          push: false\n"227                        "          cache-from: type=gha\n"228                        "          cache-to: type=gha"229                    ),230                },231                {232                    "path": "Dockerfile",233                    "type": "dockerfile",234                    "content": (235                        "FROM python:3.9-slim\n"236                        "WORKDIR /app\n"237                        "COPY . .\n"238                        'CMD ["python", "app.py"]'239                    ),240                },241            ],242            "error": {243                "phase": "docker_build",244                "message": (245                    "ERROR: cache export feature is currently not supported for docker driver. "246                    "Please switch to a different driver"247                ),248                "exit_code": 1,249                "failed_step": "Build",250            },251            "expected_fixes": [252                {253                    "file": ".github/workflows/build.yml",254                    "type": "contains",255                    "expected": "cache-to: type=gha,mode=max",256                    "hint": "GHA cache needs mode=max for proper cache export",257                }258            ],259        },260 261        # Scenario 5: Push without login262        {263            "id": "push_without_login",264            "files": [265                {266                    "path": ".github/workflows/build.yml",267                    "type": "workflow",268                    "content": (269                        "name: Build and Push\n"270                        "on:\n"271                        "  push:\n"272                        "    tags: ['v*']\n"273                        "\n"274                        "jobs:\n"275                        "  build:\n"276                        "    runs-on: ubuntu-latest\n"277                        "    steps:\n"278                        "      - uses: actions/checkout@v4\n"279                        "      - name: Build image\n"280                        "        run: docker build -t myuser/myapp:${{ github.ref_name }} .\n"281                        "      - name: Push image\n"282                        "        run: docker push myuser/myapp:${{ github.ref_name }}"283                    ),284                },285                {286                    "path": "Dockerfile",287                    "type": "dockerfile",288                    "content": (289                        "FROM python:3.11-slim\n"290                        "WORKDIR /app\n"291                        "COPY . .\n"292                        'CMD ["python", "app.py"]'293                    ),294                },295            ],296            "error": {297                "phase": "push",298                "message": "denied: requested access to the resource is denied — not logged in to registry",299                "exit_code": 1,300                "failed_step": "Push image",301            },302            "expected_fixes": [303                {304                    "file": ".github/workflows/build.yml",305                    "type": "contains",306                    "expected": "docker login",307                    "hint": "Add a Docker login step before pushing to a registry",308                },309            ],310        },311    ]312