agentsclimarketplace

Analyze docker build errors

Skill dykyi-roman/awesome-claude-code/skills/analyze-docker-build-errors

Analyzes Docker build errors for PHP projects. Identifies extension compilation failures, dependency issues, memory limits, and provides fixes.From its SKILL.md

Install
npx -y skills add dykyi-roman/awesome-claude-code --skill analyze-docker-build-errors

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

5.1 KB, as published. Nobody here has run it

Docker Build Error Analysis

Analyze Dockerfile and build logs for PHP project build failures and provide targeted fixes.

Common Build Error Patterns

Error CategorySymptomRoot Cause
Extension compilationconfigure: error: ...Missing dev packages
Package not foundE: Unable to locate packageWrong package name for base image
Permission deniedCOPY failed: permission deniedFile ownership or Docker socket
Memory exhaustedAllowed memory size exhaustedComposer or PHP memory limit
Context too largesending build context... 2GBMissing .dockerignore
Multi-stage failureCOPY --from=builder ... not foundWrong stage name or path

Detection Patterns

1. Extension Compilation Failure

# ERROR: gd extension on Alpine
RUN docker-php-ext-install gd
# configure: error: png.h not found

# FIX (Alpine):
RUN apk add --no-cache libpng-dev libjpeg-turbo-dev freetype-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

# FIX (Debian):
RUN apt-get update && apt-get install -y libpng-dev libjpeg62-turbo-dev libfreetype6-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

2. Extension Dependencies by Base Image

ExtensionAlpine PackagesDebian Packages
gdlibpng-dev libjpeg-turbo-dev freetype-devlibpng-dev libjpeg62-turbo-dev libfreetype6-dev
intlicu-devlibicu-dev
ziplibzip-devlibzip-dev
pdo_pgsqlpostgresql-devlibpq-dev
soaplibxml2-devlibxml2-dev
xsllibxslt-devlibxslt1-dev
imagickimagemagick-dev (PECL)libmagickwand-dev (PECL)

3. Memory Exhausted During Build

# ERROR: Composer runs out of memory
RUN composer install
# PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

# FIX: Increase memory limit for Composer
RUN php -d memory_limit=-1 /usr/bin/composer install --no-dev --optimize-autoloader

4. Context Too Large

# Required .dockerignore entries
.git
node_modules
vendor
var/cache
var/log
docker-compose*.yml
.env.local
tests
docs

5. Alpine Build Essentials

RUN apk add --no-cache --virtual .build-deps \
    $PHPIZE_DEPS build-base autoconf \
    && pecl install redis \
    && docker-php-ext-enable redis \
    && apk del .build-deps

Grep Patterns

# Find Dockerfiles with extension installs
Grep: "docker-php-ext-install" --glob "**/Dockerfile*"

# Find missing dev package installs before ext-install
Grep: "ext-install.*(gd|intl|zip|pdo_pgsql|imagick)" --glob "**/Dockerfile*"

# Find unrestricted memory Composer runs
Grep: "composer install|composer update" --glob "**/Dockerfile*"

# Find large base images
Grep: "FROM php:[0-9.]+-apache|FROM php:[0-9.]+-cli$" --glob "**/Dockerfile*"

# Check for .dockerignore existence
Glob: "**/.dockerignore"

Root Cause Analysis

Build Fails on CI but Works Locally

  1. Different Docker version -- check docker version output
  2. No BuildKit -- CI may not have DOCKER_BUILDKIT=1
  3. Cache differences -- CI has cold cache, local has warm
  4. Platform mismatch -- local ARM (M1/M2), CI AMD64

Extension Fails Only on Alpine

  1. musl vs glibc -- some extensions require glibc patches
  2. Package naming -- Alpine uses different package names
  3. Missing build tools -- add build-base for compilation

Fix Templates

Alpine

RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS <DEV_PACKAGES> \
    && docker-php-ext-configure <EXT> <OPTIONS> \
    && docker-php-ext-install -j$(nproc) <EXT> \
    && apk del .build-deps \
    && apk add --no-cache <RUNTIME_PACKAGES>

Debian

RUN apt-get update \
    && apt-get install -y --no-install-recommends <DEV_PACKAGES> \
    && docker-php-ext-configure <EXT> <OPTIONS> \
    && docker-php-ext-install -j$(nproc) <EXT> \
    && apt-get purge -y --auto-remove <DEV_ONLY_PACKAGES> \
    && rm -rf /var/lib/apt/lists/*

Severity Classification

PatternSeverityImpact
Extension compile failureCriticalBuild completely blocked
Memory exhaustedCriticalBuild cannot complete
Package not foundMajorBuild blocked, easy fix
Context too largeMajorSlow builds, wasted bandwidth
COPY path errorMinorBuild blocked, trivial fix

Output Format

### Build Error: [Category]

**Severity:** Critical/Major/Minor
**Stage:** `FROM ... AS <stage>`
**Line:** Dockerfile:line

**Error Message:**
<exact error from build log>

**Root Cause:**
[Explanation of why the build fails]

**Fix:**
```dockerfile
// Corrected Dockerfile instruction

Prevention: [How to avoid this error in future builds]

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.