Skip to main content

Tool for buildah scripts

Project description

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

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

buildahscript-0.3.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

buildahscript-0.3.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file buildahscript-0.3.0.tar.gz.

File metadata

  • Download URL: buildahscript-0.3.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for buildahscript-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0e0abe129f355627a03e16f9b2dd76fe3e3c9763ab05b378c51cbf75d7e59366
MD5 7081a22400b228d73dd236089990ad3d
BLAKE2b-256 6128184559ffa8a28c5c6657f9d3e54db153cdc7df1b47426d06d9b682c3f58d

See more details on using hashes here.

File details

Details for the file buildahscript-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: buildahscript-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for buildahscript-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfb159f008407c1b69fadac37b7ad085cf30fbee11823725be906c626f956295
MD5 282d1439e61031224fec5b6a99eab207
BLAKE2b-256 b2f724ab833b5b01abb67b7489bb740a3e344f625686fa6bc053cbeeed2383a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page