weisser-dev/awesome-opencode/docker-optimize
Claude Code and agent skill by weisser-dev/awesome-opencode
- community
Checking that the SKILL.md file is still in the repository.
Analyze Dockerfile and produce optimized version with multi-stage builds, layer caching, minimal base, and security hardening
Install
npx vskill@latest install weisser-dev/awesome-opencode/docker-optimizeSKILL.md
The same SKILL.md was published earlier as weisser-dev/awesome-opencode/docker-optimize.
What I do
- Analyze existing Dockerfile for inefficiencies and security issues
- Produce an optimized version with multi-stage builds
- Maximize layer caching for faster builds
- Select minimal base images to reduce attack surface
- Apply security hardening best practices
When to use me
Use this skill when you need to:
- Optimize a Dockerfile for smaller image size or faster builds
- Harden a container image for production deployment
- Convert a single-stage Dockerfile to multi-stage
- Debug slow Docker builds or bloated images
- Review a Dockerfile for security best practices
Process
- Analyze: Read the existing Dockerfile and
.dockerignore
- Identify the application type and runtime requirements
- Note current base image and its size
- Check for anti-patterns (see checklist below)
- Optimize base image: Select the smallest viable base
alpinevariants for minimal footprintdistrolessfor production (no shell, no package manager)slimvariants as a middle ground- Pin exact image digest or version tag, never use
latest
- Implement multi-stage build: Separate build and runtime
```dockerfile # Build stage FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci --production=false COPY . . RUN npm run build
# Production stage FROM node:20-alpine AS production WORKDIR /app COPY --from=build /app/dist ./dist COPY --from=build /app/node_modules ./node_modules USER node EXPOSE 3000 CMD ["node", "dist/index.js"] ```
- Maximize layer caching: Order instructions by change frequency
- Copy dependency manifests first, install, then copy source
- Group rarely-changing instructions early in the Dockerfile
- Use
.dockerignoreto exclude unnecessary files
- Security hardening: Apply container security best practices
- Run as non-root user
- Drop all capabilities, add only what is needed
- Set
HEALTHCHECKinstruction - Avoid storing secrets in image layers
- Use
COPYinstead ofADDunless tar extraction is needed
- Validate: Verify the optimized image
- Compare image size before and after
- Confirm the application starts correctly
- Run a vulnerability scan on the final image
Anti-Pattern Checklist
- [ ] Using
latesttag for base image - [ ] Running as root user
- [ ] Installing unnecessary packages (build tools in production image)
- [ ] Copying entire context before installing dependencies
- [ ] Using
ADDwhenCOPYsuffices - [ ] Not using
.dockerignore - [ ] Storing secrets in
ENVorARGinstructions - [ ] Multiple
RUNcommands that should be combined - [ ] Not cleaning up package manager caches in the same layer
Optimization Targets
| Metric | Goal | |
|---|---|---|
| Image size | Reduce by 50%+ from naive build | |
| Build time (cached) | Under 30 seconds for source-only changes | |
| Security | No critical/high CVEs in base image | |
| Layers | Minimize total layer count |
Language-Specific Patterns
Java
Go
Rules
- Always pin base image versions explicitly
- Never store secrets or credentials in the image
- Always run the final container as a non-root user
- Combine
RUNcommands to reduce layers and clean up in the same layer - Include a
.dockerignorethat excludes.git,node_modules, and build artifacts
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcli-tool/templates/skills/docker-optimize/SKILL.md
Popularity
- Repository stars
- 13
- Repository forks
- 1
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/weisser-dev/awesome-opencode/docker-optimize)