跳转到主要内容

用于构建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: 定义构建参数,采用Python name:type=default 形式,其中type是类型/解析函数的点形式名称,default是Python字面量。

许可

本软件包可在Prosperity公共许可证下免费用于商业目的的试用期。

长期商业使用的许可证可通过licensezero.com获得。

licensezero.com pricing

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。

源代码发行版

buildahscript-0.4.0.tar.gz (11.8 kB 查看哈希值)

上传时间 源代码

构建发行版

buildahscript-0.4.0-py3-none-any.whl (12.3 kB 查看哈希值)

上传时间 Python 3

支持