Sign inSign up

pytgaen/py-uv-genesis

By pytgaen

•Updated 2 days ago

🐳 Python image that includes UV and a dev variant with tools (Ruff, Trivy, ...)

Image
Languages & frameworks
0

7.7K

pytgaen/py-uv-genesis repository overview

⁠🚀 py-uv-genesis

py-uv-genesis is a 🐳 Docker-based Python development environment that includes various tools for Python development, dependency management, and security scanning. It's designed to supercharge your Python projects! 🔋

⁠🌟 Versions

  • Base Versions: Available for Python 3.9, 3.10, 3.11, 3.12 and 3.13, including only uv for package management
  • Development Versions: Include all features and tools (Available for Python 3.9, 3.10, 3.11, 3.12 and 3.13)

⁠🛠️ Features

⁠🐍 Base Versions
  • Available for Python 3.9, 3.10, 3.11, 3.12 and 3.13
  • Based on slim Debian Bookworm images
  • Includes uv for Python package management
⁠🚀 Development Versions
  • Based on Python slim Debian Bookworm images
  • Includes essential development tools and utilities
  • Pre-installed security scanning tools (Trivy and Syft)
  • YAML parsing with yq
  • Python package management with uv
  • Code linting with ruff

⁠🧰 Included Tools

⁠🐍 Base Versions
  • Python (3.9, 3.10, 3.11, 3.12 or 3.13)
  • uv⁠ - Python package installer and resolver
⁠🚀 Development Versions

⁠🚀 Usage

  1. Build the Docker image:
# For base versions (replace X.Y with 3.9, 3.10, 3.11, 3.12 or 3.13)
docker build -t py-uv-genesis:X.Y -f Dockerfile.base --build-arg PYTHON_VERSION=X.Y .

# For development versions (replace X.Y with 3.9, 3.10, 3.11, 3.12 or 3.13)
docker build -t py-uv-genesis:X.Y-dev -f Dockerfile.dev --build-arg PYTHON_VERSION=X.Y .
  1. Run a container:
# For base versions
docker run -it --rm py-uv-genesis:X.Y

# For development versions
docker run -it --rm py-uv-genesis:X.Y-dev

Examples:

# Build and run Python 3.9 base version
docker build -t py-uv-genesis:3.9 -f Dockerfile.base --build-arg PYTHON_VERSION=3.9 .
docker run -it --rm py-uv-genesis:3.9

# Build and run Python 3.9 development version
docker build -t py-uv-genesis:3.9-dev -f Dockerfile.dev --build-arg PYTHON_VERSION=3.9 .
docker run -it --rm py-uv-genesis:3.9-dev

This will start an interactive Python shell. You can modify the CMD in the Dockerfile to run your specific Python script or application.

⁠🛠️ Customization

You can customize the Dockerfiles to add or remove tools as needed for your project. The current setup provides a solid foundation for Python development with security scanning capabilities in the development versions, and a lightweight environment with uv in the base versions.

⁠🎯 Usage Examples

⁠🚀 Basic Usage
  1. Create a Python file, e.g., hello.py:
print("Hello from py-uv-genesis!")
  1. Run the script using the py-uv-genesis container:
docker run -it --rm -v $(pwd):/app py-uv-genesis:3.11-dev python /app/hello.py
⁠📦 Package Management with uv
  1. Create a requirements.txt file:
requests==2.26.0
  1. Install packages and run a Python script:
docker run -it --rm -v $(pwd):/app py-uv-genesis:3.11-dev sh -c "uv pip install -r /app/requirements.txt && python /app/your_script.py"
⁠🛡️ Security Scanning

Run Trivy to scan your project for vulnerabilities:

docker run -it --rm -v $(pwd):/app py-uv-genesis:3.11-dev trivy filesystem /app
⁠💻 Interactive Python Shell

Start an interactive Python shell with all tools available:

docker run -it --rm py-uv-genesis:3.11-dev

⁠🔧 Using with VS Code Dev Containers

py-uv-genesis can be easily integrated with VS Code Dev Containers for a seamless development experience.

  1. Install the "Remote - Containers" extension in VS Code.

  2. Create a .devcontainer folder in your project root.

  3. Add a devcontainer.json file in the .devcontainer folder:

{
    "name": "py-uv-genesis",
    "image": "py-uv-genesis:3.11-dev",
    "extensions": [
        "ms-python.python",
        "ms-python.vscode-pylance"
    ],
    "settings": {
        "python.defaultInterpreterPath": "/usr/local/bin/python",
        "python.linting.enabled": true,
        "python.linting.pylintEnabled": false,
        "python.linting.ruffEnabled": true,
        "python.formatting.provider": "ruff"
    },
    "postCreateCommand": "uv pip install -r requirements.txt"
}
  1. Open your project in VS Code and click on the "Reopen in Container" button when prompted, or use the command palette to select "Remote-Containers: Reopen in Container".

This setup will provide you with a fully configured Python development environment using py-uv-genesis, complete with linting, formatting, and dependency management.

⁠🤝 Contributing

Contributions to improve py-uv-genesis are welcome! Please feel free to submit pull requests or open issues to suggest improvements or report bugs. Let's make this tool even better together! 💪

⁠📄 License

py-uv-genesis is open-source software licensed under the GNU General Public License (GPL). This means you are free to use, modify, and distribute this software, but any derivative work must also be distributed under the same license terms.

For the full license text, please see the LICENSE file in the repository. Below is a brief summary of the GPL:

  • You are free to use, modify, and distribute this software.
  • If you distribute modified versions, you must make your modifications available under the GPL.
  • You must include the original copyright notice and the license text.
  • There is no warranty for this software.

Please note that this summary is not a substitute for the full license text. Make sure to read and understand the full GPL license before using or contributing to this project.


Happy coding! 🎉 If you find py-uv-genesis useful, don't forget to give it a star on Gitlab! ⭐

Tag summary

Content type

Image

Digest

sha256:4a108bfec…

Size

170.9 MB

Last updated

2 days ago

docker pull pytgaen/py-uv-genesis:3.10-dev