Argument Features:
- build args
- tags
Language features:
- Front matter
- Required pip packages
- Build arg conversions
- build args
- return an image
- Container.open(): "Opens" a file inside the container (lots of buffering happening), object has additional methods for chown, chmod, stat, etc
- Container.copy_out(): Copies a file/directory from container to host (mount, copy, unmount)
- Container.run(): Accepts all arguments of subprocess.run() (requires a lot of magic)
Additional
- Makes sure script is run inside
buildah unshare, so a bunch of stuff (most everyting) works correctly. (See:$_CONTAINERS_USERNS_CONFIGURED)
#!/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 workspace('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 workspace('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 workspace('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')
# Build /mc
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.cmd = ["/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 specifierarg: Defines a build arg, in the Pythonname:type=defaultform, 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.
Metadata
Release files for buildahscript 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| buildahscript-0.1.1.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| buildahscript-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.7 kB
Release files / buildahscript-0.1.1.tar.gz
| Download URL | buildahscript-0.1.1.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8e7a2735009a7d6a75ee0a25598afc5903b3cb7f64a18f229ec6729ff988ea9
|
|
BLAKE2b-256 checksum How to use checksums |
e4c6931cd0f4569d83a2f7a8a294892e4a008798c60aa8144b3fbf7518a89558
|
| 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.1.1-py3-none-any.whl
| Download URL | buildahscript-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5efc5b9b6f29cb9dc018139a702229425403f4b3bf8027dd94cbcc8d97daaa9f
|
|
BLAKE2b-256 checksum How to use checksums |
f9df7c39bdf1b2894ee0b26afc06f7e350ffcb13b44f7edef248ea64c4cb4ab4
|
| 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
|