用于构建ah脚本的工具
项目描述
buildahscript
buildahscript是一种新的容器定义语言,旨在具有命令性和灵活性。
它允许您使用buildargs做更多事情,创建真正可重用的模块,并在一般情况下创建更灵活的容器构建器。
示例
#!/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 (#|
) 行用于指定buildahscript使用的元数据。基本形式是 #| type: data
。
pip
: 从PyPI安装依赖项,作为一个需求指定符arg
: 定义构建参数,采用Pythonname:type=default
形式,其中type是类型/解析函数的点形式名称,default是Python字面量。
许可
本软件包可在Prosperity公共许可证下免费用于商业目的的试用期。
长期商业使用的许可证可通过licensezero.com获得。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。
源代码发行版
buildahscript-0.4.0.tar.gz (11.8 kB 查看哈希值)
构建发行版
buildahscript-0.4.0-py3-none-any.whl (12.3 kB 查看哈希值)
关闭
buildahscript-0.4.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8cf3b762a1899990e9d343dc44a198eb3eb05da0dcdc067faff60fd73af060ea |
|
MD5 | b1e4145c037977fe912b1d92dba47a1b |
|
BLAKE2b-256 | 1dd64e55fb3ccb4a24f55547a8f61e373c3b3330690a87c39c86dccc2c0187ce |
关闭
buildahscript-0.4.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3e2c72b9a41bc4ef800690131c1541c9df60dbd1c856bdcb1ccf528005d6ccf4 |
|
MD5 | 112959bb6d2f4e9ddab38214db6929ef |
|
BLAKE2b-256 | bc7a33bad1f9fe0782ed691a87ab2e1f92cf7b9a125c6f58c0188d87f05e1895 |