Skip to main content

AI-powered Dockerfile generation and analysis

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Dockerfile Assistant

AI-powered CLI tool that generates production-ready Dockerfiles and .dockerignore files for Python and Node.js projects.

Features

  • Multi-Provider LLM Support - OpenAI, Google (Gemini), Anthropic (Claude), Groq, and Ollama (local)
  • Automatic Stack Detection - Detects Python/Node.js, package managers, entry points, and ports
  • Production-Ready Templates - Multi-stage builds, non-root users, health checks
  • Filesystem MCP Integration - Optional AI-powered file exploration and generation
  • Interactive CLI - Chat-based interface with multi-turn conversations

Installation

pip install dockerfile-assistant

From Source

git clone https://github.com/giulianotesta7/dockerfile-assistant.git
cd dockerfile-assistant
pip install -e .

Configuration

Create a .env file in your working directory:

# Required
LLM_PROVIDER=openai # ollama/google/anthropic/groq
MODEL_NAME=gpt-4o-mini

# API Key (based on provider)
OPENAI_API_KEY=sk-...
# GOOGLE_API_KEY=...
# ANTHROPIC_API_KEY=...
# GROQ_API_KEY=...
# OLLAMA_BASE_URL=http://localhost:11434/v1

# Optional - Enable filesystem access for AI
USE_FS_MCP=false 
# Only if USE_FS_MCP is set on true
PROJECT_PATH=/path/to/your/project
OUTPUT_PATH=/path/to/output 

Supported Providers

Provider Model Examples Required Variable
openai gpt-4 OPENAI_API_KEY
google gemini-pro GOOGLE_API_KEY
anthropic claude-sonnet ANTHROPIC_API_KEY
groq llama-3.3-70b-versatile GROQ_API_KEY
ollama llama3.1:8b OLLAMA_BASE_URL

Usage

dockerfile-assistant

Mode Comparison

Feature Basic Mode MCP Mode
User provides project info Yes Optional
Auto-detects stack No Yes
Auto-detects dependencies No Yes
Reads project files No Yes
Saves files to disk No Yes
Required env vars LLM_PROVIDER, MODEL_NAME, API key + PROJECT_PATH, OUTPUT_PATH

Basic Mode

Required input: Describe your project to the agent (stack, package manager, port, start command).

If there is missing information, AI will ask you for:

  • Stack (Python or Node.js)
  • Package manager (pip, poetry, npm, yarn, pnpm)
  • Container port
  • Start command

Then generates a Dockerfile and .dockerignore.

Note: For Ollama, llama3.1:8b was used during development testing. The OLLAMA_BASE_URL must include /v1 (e.g., http://localhost:11434/v1).

MCP Mode (USE_FS_MCP=true)

Required input: Just ask "Generate a Dockerfile for my project" - the AI explores your project automatically.

When enabled, the AI can:

  • Explore your project directory automatically (PROJECT_PATH)
  • Detect stack from file signatures (package.json, requirements.txt, etc.)
  • Find entry points and ports from configuration
  • Save generated files directly to OUTPUT_PATH (Dockerfile, .dockerignore)
# Set in .env
USE_FS_MCP=true
PROJECT_PATH=/path/to/your/project
OUTPUT_PATH=/path/to/your/project

Important: MCP mode requires a model that supports tool/function calling.

Note: Ollama with small models (< 30B parameters) is not recommended for MCP mode. Small local models may struggle with tool calling and file exploration, leading to unexpected behavior. For MCP mode, use larger models or cloud providers (OpenAI, Google, Anthropic).

Security: The AI cannot read or write .env files. Access is blocked for security reasons.

Generated Dockerfile Features

All generated Dockerfiles include:

  • Multi-stage builds for optimized image size
  • Non-root user for security
  • Health checks for container orchestration
  • Optimized base images (python:3.12-slim, node:20-alpine)

Supported Stacks

Stack Package Managers
Python pip, poetry
Node.js npm, yarn, pnpm

Environment Variables Reference

Variable Required Description
LLM_PROVIDER Yes Provider: openai, google, anthropic, groq, ollama
MODEL_NAME Yes Model identifier for the provider
OPENAI_API_KEY If openai OpenAI API key
GOOGLE_API_KEY If google Google AI API key
ANTHROPIC_API_KEY If anthropic Anthropic API key
GROQ_API_KEY If groq Groq API key
OLLAMA_BASE_URL If ollama Ollama server URL
USE_FS_MCP No Enable filesystem MCP (true/false)
PROJECT_PATH If MCP Path to project directory
OUTPUT_PATH If MCP Path for output files

Requirements

  • Python 3.10+
  • Node.js (only if using MCP filesystem features)

License

MIT License - see LICENSE for details.

Author

Giuliano Testa (@giulianotesta7)

Acknowledgments

  • System prompts were crafted with the assistance of Claude (Anthropic)
  • Built with Pydantic AI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockerfile_assistant-1.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dockerfile_assistant-1.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file dockerfile_assistant-1.2.0.tar.gz.

File metadata

  • Download URL: dockerfile_assistant-1.2.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dockerfile_assistant-1.2.0.tar.gz
Algorithm Hash digest
SHA256 5e210d3ba582cd3edb7ddadd9c90dae86b0bd260482ca6e7865bea1fe3c186ea
MD5 cc8ebd031a23347ca76dffc6424de0b3
BLAKE2b-256 86d57153abdc65621d1dfdafeee56dfb36ed61fcdff352c4107065baf3594d00

See more details on using hashes here.

File details

Details for the file dockerfile_assistant-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dockerfile_assistant-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27d6440291e006e381afa0dc454995db8fadcde726dc1d8f7337e2a01f47696e
MD5 2361fc7298cfa9abf397117f31af1ccc
BLAKE2b-256 6066bb076dff79037df242d4963f4e9014dd4fdd543341f90ec6beda442d4f3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page