containerfile-creator
БесплатноБез исполняемых скриптовНе проверенCreate high-quality, secure, and performance-optimized Containerfiles (Dockerfiles) following best practices for multi-architecture builds…
от jim60105★ 22 звезды на GitHubОб этом скилле
Containerfile Creator
Create secure, efficient, and maintainable container images following open source best practices.
Workflow
- Determine the project language/framework
- Check host environment for SELinux enforcement (e.g.
getenforce) if using Podman/Buildah - Load the appropriate reference file for examples (see Language-Specific References below)
- Apply the core structure and patterns from this document
- Write the Containerfile following the Final Stage Instruction Ordering
File Naming
- Prefer
ContainerfileoverDockerfile - Use descriptive names for variants:
alpine.Containerfile,distroless.Containerfile,ubi.Containerfile
Required Syntax Declaration
Every file MUST start with:
# syntax=docker/dockerfile:1
ARG Definition Block
Only UID, VERSION, and RELEASE go at the top level:
# syntax=docker/dockerfile:1
ARG UID=1001
ARG VERSION=EDGE
ARG RELEASE=0
TARGETARCH and TARGETVARIANT MUST be declared inside each stage that uses them, not globally.
Multi-stage Build Structure
########################################
# Build stage
########################################
FROM python:3.13-alpine AS build
########################################
# Final stage
########################################
FROM python:3.13-alpine AS final
- Always name the last stage
final - Use 40
#characters for stage separators - Only use a separate
basestage when it requires non-trivial setup (e.g., installing system packages on UBI/Debian)
Cache Optimization
Declare multi-arch variables inside each stage that uses cache mounts:
ARG TARGETARCH
ARG TARGETVARIANT
Package Manager Cache Patterns
# Alpine APK
RUN --mount=type=cache,id=apk-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apk \
apk update && apk add -u package-name
# Debian/Ubuntu APT
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=aptlists-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/lib/apt/lists \
apt-get update && apt-get install -y --no-install-recommends package-name
# Python PIP
RUN --mount=type=cache,id=pip-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/root/.cache/pip \
pip install package-name
# Python UV
RUN --mount=type=cache,id=uv-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/root/.cache/uv \
uv pip install package-name
# DNF (Fedora/RHEL)
RUN --mount=type=cache,id=dnf-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/dnf \
dnf -y install package-name
Security and Permissions
Create Non-root User
# Alpine
ARG UID
RUN adduser -g "" -D $UID -u $UID -G root
# Debian/Ubuntu
ARG UID
RUN groupadd -g $UID $UID && \
useradd -l -u $UID -g $UID -m -s /bin/sh -N $UID
OpenShift Compatibility (Arbitrary UID)
# Create directories
RUN install -d -m 775 -o $UID -g 0 /app && \
install -d -m 775 -o $UID -g 0 /licenses
# Copy files with proper ownership
COPY --link --chown=$UID:0 --chmod=775 source dest
License Files (Required)
COPY --link --chown=$UID:0 --chmod=775 LICENSE /licenses/Containerfile.LICENSE
COPY --link --chown=$UID:0 --chmod=775 project/LICENSE /licenses/project.LICENSE
SELinux Compatibility (Rootless Podman / Bind Mounts)
By default, all code examples in this skill assume standard environments without SELinux or default Docker daemon execution. However, on SELinux-enforcing systems (such as Fedora, RHEL, CentOS) when using Podman or Buildah, --mount=type=bind instructions will fail with Permission denied (os error 13) because the container process cannot access host files without explicit SELinux security context relabeling.
SELinux Workflow & Verification Guidelines
- Verify System Status: Check if SELinux is active (e.g.
getenforceoutputsEnforcing). - Inform / Consult User:
- Inform the user if an SELinux environment is detected and explain why
,relabel=shared(or,relabel=private) is required on--mount=type=bind. - Explicitly confirm with the user or state whether SELinux-compatible syntax (
relabel=shared) or standard Docker syntax is being used.
- Inform the user if an SELinux environment is detected and explain why
- Containerfile & Documentation Requirements:
- When SELinux relabeling is adopted, clearly document it with inline comments in the
Containerfile/Dockerfile:# Note: relabel=shared is required for SELinux (Podman/Fedora/RHEL) rootless bind mounts RUN --mount=type=cache,id=uv-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/root/.cache/uv \ --mount=type=bind,source=pyproject.toml,target=pyproject.toml,relabel=shared \ --mount=type=bind,source=uv.lock,target=uv.lock,relabel=shared \ uv sync --frozen --no-dev --no-install-project --no-editable - Document the SELinux build requiremen
- When SELinux relabeling is adopted, clearly document it with inline comments in the
Установить containerfile-creator в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл containerfile-creator?
Create high-quality, secure, and performance-optimized Containerfiles (Dockerfiles) following best practices for multi-architecture builds, OpenShift/Kubernetes compatibility, and BuildKit cache optimization. Use when the user wants to: (1) create a new Containerfile or Dockerfile for any project (Python, Rust, Go, Node.js, .NET, or any language), (2) containerize an application with multi-stage builds, (3) optimize an existing Containerfile for security, performance, or image size, (4) review or improve container image build practices, (5) set up BuildKit cache mounts for package managers, (6) create OpenShift-compatible container images with non-root users and arbitrary UID support, (7) write a .dockerignore file, or (8) apply OCI LABEL standards.
Как установить скилл containerfile-creator?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл containerfile-creator запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic