nixpacks-python
is a Python library for building source images using Nixpacks.
- Rust toolchain (with Cargo)
- Python 3.x
-
Clone the Repository:
git clone https://github.com/musab-tatek/nixpacks-python.git
-
Navigate to the Project Directory:
cd nixpacks-python
-
Install with Maturin:
maturin develop
This command will build the Rust crate and make the Python module available for development use.
import nixpacks_python
path = "/path/to/your/project"
env_vars = ["VAR1=value1", "VAR2=value2"]
providers = nixpacks_python.detect(path, env_vars)
print(providers)
path = "/path/to/your/project"
env_vars = ["VAR1=value1", "VAR2=value2"]
json_plan = '{"phases": [...]}' # JSON representation of a build plan
install_cmds = ["npm install", "pip install -r requirements.txt"]
build_cmds = ["make build"]
start_cmd = "python app.py"
apt_pkgs = ["build-essential"]
nix_pkgs = ["python3"]
plan = nixpacks_python.plan(path, env_vars, json_plan, install_cmds, build_cmds, start_cmd, apt_pkgs, nix_pkgs)
print(plan)
path = "/path/to/your/project"
name = "my_image"
out_dir = "/output"
print_dockerfile = True
tags = ["latest", "v1.0"]
labels = ["author=John Doe", "version=1.0"]
quiet = False
cache_key = "my_cache_key"
no_cache = False
inline_cache = True
cache_from = "previous_image:latest"
platform = ["linux/amd64"]
current_dir = True
no_error_without_start = False
incremental_cache_image = "incremental_cache:latest"
cpu_quota = "2"
memory = "4G"
verbose = False
docker_host = "tcp://localhost:2375"
docker_tls_verify = "/path/to/cert.pem"
env_vars = ["VAR1=value1", "VAR2=value2"]
nixpacks_python.build(path, name, out_dir, print_dockerfile, tags, labels, quiet, cache_key, no_cache, inline_cache, cache_from, platform, current_dir, no_error_without_start, incremental_cache_image, cpu_quota, memory, verbose, docker_host, docker_tls_verify, env_vars)
Contributions to nixpacks-python
are welcome! If you have any ideas for improvements or new features, feel free to open an issue or submit a pull request.