Skip to main content

buildahscript

Buildahscript is a new container definition language built to be imperative and flexible.

It allows you to do more with buildargs, create actually re-usable modules, and in general create more flexible container builders.

Example

#!/usr/bin/env buildahscript-py
#| pip: requests
#| arg: eula: bool
#| arg: version: str = "latest"
#| arg: type: str = "vanilla"

import tarfile

import requests


with TemporaryDirectory() as td:
    bin = td / 'bin'
    bin.mkdir()
    with Container('rust:buster') as build:
        build.copy_in('cmd', '/tmp/cmd')
        build.copy_in('localmc', '/tmp/localmc')
        build.run(['cargo', 'build', '--release'], pwd='/tmp/cmd')
        build.copy_out('/tmp/cmd/target/release/cmd', bin / 'cmd')

    with Container('rust:buster') as build:
        build.copy_in('status', '/tmp/status')
        build.copy_in('localmc', '/tmp/localmc')
        build.copy_in('mcproto-min-async', '/tmp/mcproto-min-async')
        build.run(['cargo', 'build', '--release'], pwd='/tmp/status')
        build.copy_out('/tmp/status/target/release/status', bin / 'status')

    # Download & extract mc-server-runner
    with requests.get('https://github.com/itzg/mc-server-runner/releases/download/1.3.3/mc-server-runner_1.3.3_linux_amd64.tar.gz') as resp:
        resp.raise_for_status()
        with tarfile.open(resp, 'r|*') as tf:
            for entry in tf:
                if entry.name == 'mc-server-runner':
                    tf.extract(entry, bin / 'mc-server-runner')

    with Container('openjdk:8-jre-slim') as cont:
        cont.copy_in(bin / 'cmd', '/usr/bin/cmd')
        cont.copy_in(bin / 'status', '/usr/bin/status')
        cont.copy_in(bin / 'mc-server-runner', '/mc-server-runner')

        cont.volumes |= {
            "/mc/world", "/mc/server.properties", "/mc/logs",
            "/mc/crash-reports", "/mc/banned-ips.json",
            "/mc/banned-players.json", "/mc/ops.json", "/mc/whitelist.json",
        }
        cont.entrypoint = ["/mc-server-runner", "-shell", "/bin/sh"]
        cont.command = ["/mc/launch"]
        cont.healthcheck_cmd = ["status"]
        cont.healthcheck_start_period = "5m"

        return cont.commit()

shpipe

shpipe (#|) lines are used to specify metadata used by buildahscript. The basic form is #| type: data.

  • pip: Gives a dependency to install from PyPI, as a requirement specifier
  • arg: Defines a build arg, in the Python name:type=default form, where type is a dotted-form name to a type/parsing function, and default is a python literal.

Licensing

This package is free to use for commercial purposes for a trial period under the terms of the Prosperity Public License.

Licenses for long-term commercial use are available via licensezero.com.

licensezero.com pricing

Metadata

Release files for buildahscript 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for buildahscript 0.2.0
File Size Uploaded
buildahscript-0.2.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for buildahscript 0.2.0
File Interpreter ABI Platform
buildahscript-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / buildahscript-0.2.0.tar.gz

Download URL buildahscript-0.2.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6cc5e8476ba533bb6e59b015fe1b7f4aec25e70f2c984dcf238a41d2d68373d8
BLAKE2b-256 checksum
How to use checksums
bc8d5a3d6a9119e8e6c88934099e0f5ee40f16f62d6f0bbbcce4fcc9d9df2d1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.6

Release files / buildahscript-0.2.0-py3-none-any.whl

Download URL buildahscript-0.2.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45fc342c4c0abbdc05c7766722c8bb480e5ce20cc659c65e767dcf7ca1661e33
BLAKE2b-256 checksum
How to use checksums
c29cac087e64674fcd07397e4f3eb54b75e69e970b666257c7d3c7796bc52bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.6

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page