GithubHelp home page GithubHelp logo

nixpacks-python's Introduction

nixpacks-python

nixpacks-python is a Python library for building source images using Nixpacks.

Installation

Requirements

  • Rust toolchain (with Cargo)
  • Python 3.x

Building and Installation

  1. Clone the Repository:

    git clone https://github.com/musab-tatek/nixpacks-python.git
  2. Navigate to the Project Directory:

    cd nixpacks-python
  3. Install with Maturin:

    maturin develop

    This command will build the Rust crate and make the Python module available for development use.

Usage

Importing the Module

import nixpacks_python

Detecting Build Providers

path = "/path/to/your/project"
env_vars = ["VAR1=value1", "VAR2=value2"]

providers = nixpacks_python.detect(path, env_vars)
print(providers)

Creating Build Plans

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)

Building Docker Images

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)

Contribution

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.

nixpacks-python's People

Contributors

mu54b avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.