Skip to main content

Python-first Dockerfile optimizer CLI

Project description

docker-opt

Python-first Dockerfile optimizer CLI. It analyzes Dockerfiles, flags size/security/caching issues, outputs JSON for CI, generates a safe optimized Python template, and creates a .dockerignore.

Install

pip install docker-opt

Usage

# Analyze
docker-opt analyze -f Dockerfile

# JSON output
docker-opt analyze -f Dockerfile --json

# CI: minimal output + fail on MEDIUM and HIGH
docker-opt analyze -f Dockerfile --ci --fail-on MEDIUM

# Generate optimized template
docker-opt fix -f Dockerfile --stdout

# Write optimized template to file
docker-opt fix -f Dockerfile -o Dockerfile.optimized

# Generate .dockerignore
docker-opt dockerignore --type python
docker-opt dockerignore --type python --out .dockerignore

CI Exit Codes

  • Exit code is non-zero if any finding severity is >= --fail-on.
  • In --ci mode, output is reduced to a single summary line (unless --json).

Build and Publish

Local build (sdist/wheel + exe)

.\scripts\build.ps1
dist\docker-opt.exe --help

Publish to PyPI

.\scripts\publish.ps1           # TestPyPI
.\scripts\publish.ps1 -Target prod

Release Workflow (GitHub Actions)

  • Tag a release: vX.Y.Z
  • CI runs tests on Windows and Ubuntu.
  • Release workflow builds sdist/wheel, Windows exe, creates a GitHub Release, and uploads artifacts.
  • PyPI publishing uses trusted publishing if configured; otherwise use TWINE secrets.

Samples

  • samples/python-fastapi/ includes a minimal FastAPI app with Dockerfile and .dockerignore.

Notes

Each finding includes severity and an impact band (SECURITY, SIZE, CACHE, REPRODUCIBILITY, PERFORMANCE, MAINTAINABILITY, FUNCTIONAL, OBSERVABILITY, RELIABILITY).

Support / Donate

This project is free and open; donations help maintenance.

If docker-opt helps you, consider supporting its development:

https://buymeacoffee.com/sathsara2000

Donation URL override

You can override the donation URL with an environment variable:

$env:DOCKER_OPT_DONATION_URL = "https://example.com/your-donation-link"
docker-opt donate

Stripe Payment Link (one-time)

If you want to use Stripe for one-time donations:

  1. Sign in to Stripe and open the Dashboard.
  2. Go to Payments > Payment Links.
  3. Click New, choose One-time, and set the amount and description.
  4. Create the link and copy its URL.
  5. Set it as DOCKER_OPT_DONATION_URL or replace the link above.

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

docker_opt-0.2.0.tar.gz (17.1 MB view details)

Uploaded Source

Built Distribution

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

docker_opt-0.2.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file docker_opt-0.2.0.tar.gz.

File metadata

  • Download URL: docker_opt-0.2.0.tar.gz
  • Upload date:
  • Size: 17.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for docker_opt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 51c1dd2910030c8c3d0b5cfb684b63d59370f19f6e83946623d3521830ebd45a
MD5 d9f2c72fc7a79a639d8200aea342c895
BLAKE2b-256 b32999ab91059c0d42a20cd5d67a8c4d06e5e2e07a826c2970bd4dcff478c14d

See more details on using hashes here.

File details

Details for the file docker_opt-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: docker_opt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for docker_opt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb0a408a38e9200c7ba8bd413d2082f75455800670fdc7595be54e5bdea65779
MD5 289c9bf59bd3cb9e7a906bc3b4f9f14b
BLAKE2b-256 4a70d0c4f43c59910d9fd48ef170dd0e1ea398fd41b21fd075e35bd42e65098c

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