Skip to main content

Simple Docker Buildx CLI for local builds

Project description

build-q (bq) 🚀

build-q (pronounced bq) is a lightweight, zero-dependency Python CLI tool for streamlined local Docker Buildx operations. It auto-detects repository info from Git and reads local cicd/cicd.json to mirror production-ready builds on your local machine.


🛠 Features

  • Zero-Dependency: No external Python libraries required (only standard library).
  • Git Auto-detection: Automatically identifies repo name and branch/tag from your current directory.
  • Resource Management: Pre-configured defaults for memory and CPU limits to keep your machine responsive.
  • Auto-push: Images are pushed to the registry by default after a successful build.
  • Image Check: By default, verifies if the image already exists in the registry to avoid redundant builds (force rebuild with --rebuild or --no-image-check).
  • Default Secrets: Automatically includes $HOME/.netrc as a build secret (id=netrc).
  • Default Platform: Defaults to --platform linux/amd64 for all builds.
  • Smart Branch Detection: Sets BRANCH=production for tags starting with v*, and BRANCH=develop otherwise.
  • CI/CD Integration: Integrates with cicd/cicd.json for shared build arguments.

📦 Installation

To install build-q globally on your system, it is recommended to use pipx (or pip):

pipx install build-q

Atau melalui pip:

pip install build-q

This will provide two commands: build-q and the shorthand bq.


🚀 Usage

Simple Build (Auto-detected)

Run this inside a git repository to auto-detect the service name and branch:

bq --local

Explicit Build

bq my-service staging --local --push

Full Example (Customizing defaults)

bq plus-be-service staging \
    --secret id=custom,src=/path/to/secret \
    --platform linux/amd64 \
    --local --no-push \
    --build-arg BRANCH=custom-branch

Remote Build

Build directly from a remote Git repository without cloning locally (uses buildx git context). Defaults to SSH access.

bq user/repo v1.0.0 --remote
# Or with a full URL
bq https://github.com/user/repo.git v1.0.0 --remote

Dry Run

Check what command will be executed without actually running it:

bq my-service develop --local --dry-run

⚙️ Configuration

Initialize your local configuration file:

bq --init

This creates a config file at ~/.build-q/.env. You can edit this file to set your default registry URL and resource limits.

Configuration Options

Variable Description Default
BUILDER_NAME Name of the Docker Buildx builder mybuilder
REGISTRY_URL Default container registry URL registry.example.com
DEFAULT_MEMORY Memory limit for builds 4g
DEFAULT_CPU_PERIOD CPU period limit 100000
DEFAULT_CPU_QUOTA CPU quota limit 200000
GIT_SSH_PREFIX Default prefix for remote repo SSH access git@github.com:

🚀 Automation & Release

The project includes a Makefile for streamlined building and releasing to PyPI.

Build

To build the distribution packages:

make build

Release

To release a new version (automatically bumps the patch version, e.g., 0.1.0 -> 0.1.1):

make release

To specify a version explicitly:

make release V=1.0.0

The release process:

  1. Bumps the version in pyproject.toml and build_q/__init__.py.
  2. Builds the source and wheel distributions.
  3. Uploads to PyPI using twine.

📋 Requirements

  • Python 3.7+
  • Docker with Buildx plugin
  • Git (optional, for auto-detection)

📄 License

MIT

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

build_q-0.1.9.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

build_q-0.1.9-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file build_q-0.1.9.tar.gz.

File metadata

  • Download URL: build_q-0.1.9.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for build_q-0.1.9.tar.gz
Algorithm Hash digest
SHA256 3b99a63b740aa97a01e85c7a8848d231a31968698bafa8f30eb22f191a941663
MD5 1ff4c59df676ee92943c6c7965e2cac6
BLAKE2b-256 4bd66d43c16a2e7258e60a1233d29c6d823f7ae7aabd74e01812929655bfc6a7

See more details on using hashes here.

File details

Details for the file build_q-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: build_q-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for build_q-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 7c4e72836a21bb4a40ce2709e1a38aec4670def68f00913521e8adfe1ed36e76
MD5 ebc5c6b4f6542c7c20e6fcd61ed7263f
BLAKE2b-256 3f6917081deb23e02d5669c3c67b1a5c8ab052d5970786395e2e7760ad0f1bbf

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