Exemple #1
0
def build():
    instructions = load_instructions(CONTAINER)
    context = create_context(CONTAINER, instructions)
    dockerfile = generate_dockerfile(context)

    ## Create a dummy dockerfile
    with open(DOCKERFILE, "w") as df:
        df.write(dockerfile)

    print(dockerfile)

    return create_container(CONTAINER, context, PUBLISH)
Exemple #2
0
                content.append(f"- `{package}`")
            content.append(NEWLINE)

        if pythonpackages:
            content.append("## Python packages")
            content.append(NEWLINE)
            content.append("Package | Version \n-- | --")
            for package in sorted(pythonpackages):
                content.append(
                    f"`{package.split('==')[0]}` | {package.split('==')[1]}")
            content.append(NEWLINE)

        if INSTRUCTIONS[tag].get("documentation"):
            content.append("## Additional information")
            content.append(NEWLINE)
            content.append(INSTRUCTIONS[tag]["documentation"])

        content.append(NEWLINE)
        context = create_context(tag, load_instructions(tag))
        del context["LABEL"]
        content.append(DOCKERFILE.format(generate_dockerfile(context)))

        with open(filename, "w") as fp:
            fp.write("\n".join(content))


for filename in get_instruction_files():
    filename = filename[:-5].split("/")[-1]
    INSTRUCTIONS[filename] = load_instructions(filename)
generate_documentation()
Exemple #3
0
def generate_documentation():
    versions = get_versions()
    content = []
    content.append("# ludeeus/container")
    content.append(NEWLINE)
    content.append(
        "Click on the tag name below to see the documentation for a specific tag:"
    )
    content.append(NEWLINE)

    for tag in sorted(INSTRUCTIONS):
        content.append(f"[{tag}](./tags/{tag})  ")

    with open("./docs/index.md", "w") as fp:
        fp.write("\n".join(content))

    for tag in INSTRUCTIONS:
        filename = f"./docs/tags/{tag}.md"

        content = []
        envs = {}
        alpinepackages = []
        debianpackages = []
        pythonpackages = []

        for env in INSTRUCTIONS[tag].get("env", []):
            envs[env] = INSTRUCTIONS[tag]["env"][env]

        for package in INSTRUCTIONS[tag].get("alpine-packages", []):
            alpinepackages.append(package)

        for package in INSTRUCTIONS[tag].get("debian-packages", []):
            debianpackages.append(package)

        for package in INSTRUCTIONS[tag].get("python-packages", []):
            pythonpackages.append(package)

        content.append(f"# {tag}")
        content.append(NEWLINE)

        content.append("[Back to overview](../index.md)")
        content.append(NEWLINE)

        if INSTRUCTIONS[tag].get("description"):
            content.append(f"_{INSTRUCTIONS[tag]['description']}_")
            content.append(NEWLINE)

        content.append(f"**Base image**: `{INSTRUCTIONS[tag]['base']}`  ")

        content.append(f"**Full name**: `ludeeus/container:{tag}`  ")
        content.append(
            f"[View this on Docker Hub](https://hub.docker.com/r/ludeeus/container/tags?page=1&name={tag})"
        )
        content.append(NEWLINE)

        content.append("## Environment variables")
        content.append(NEWLINE)
        content.append("Variable | Value \n-- | --")
        for env in sorted(envs):
            content.append(f"`{env}` | {envs[env]}")
        content.append(NEWLINE)

        if INSTRUCTIONS[tag].get("features"):
            content.append("## Features")
            content.append(NEWLINE)
            for feature in sorted(INSTRUCTIONS[tag].get("features")):
                if "dotnet5" in tag and "dotnetcore" in feature and "5" not in feature:
                    continue
                if feature in versions["special"]:
                    content.append(
                        f"- `{feature} ({versions['special'][feature]})`")
                else:
                    content.append(f"- `{feature}`")
            content.append(NEWLINE)

        if alpinepackages:
            content.append("## Alpine packages")
            content.append(NEWLINE)
            content.append("Package | Version \n-- | --")
            for package in sorted(alpinepackages):
                content.append(
                    f"`{package.split('=')[0]}` | {package.split('=')[1]}")
            content.append(NEWLINE)

        if debianpackages:
            content.append("## Debian packages")
            content.append(NEWLINE)
            for package in sorted(debianpackages):
                content.append(f"- `{package}`")
            content.append(NEWLINE)

        if pythonpackages:
            content.append("## Python packages")
            content.append(NEWLINE)
            content.append("Package | Version \n-- | --")
            for package in sorted(pythonpackages):
                content.append(
                    f"`{package.split('==')[0]}` | {package.split('==')[1]}")
            content.append(NEWLINE)

        if INSTRUCTIONS[tag].get("documentation"):
            content.append("## Additional information")
            content.append(NEWLINE)
            content.append(INSTRUCTIONS[tag]["documentation"])

        content.append(NEWLINE)
        context = create_context(tag, load_instructions(tag))
        del context["LABEL"]
        content.append(DOCKERFILE.format(generate_dockerfile(context)))

        with open(filename, "w") as fp:
            fp.write("\n".join(content))
Exemple #4
0
    context = add_alpine_build_packages(context, instructions)
    context = add_debian_packages(context, instructions)
    context = add_python_packages(context, instructions)

    context = add_features(context, instructions)

    for run in instructions.get("run", []):
        context["RUN"].append(run)

    context = cleanup_alpine_packages(context, instructions)
    context = cleanup_alpine_build_packages(context, instructions)
    context = cleanup_debian_packages(context, instructions)
    context = cleanup_python_packages(context, instructions)
    context = cleanup_general(context, instructions)

    return context


if __name__ == "__main__":
    import sys
    from scripts.build.instructions import load_instructions
    from scripts.build.dockerfile import generate_dockerfile
    from scripts.build.container import DOCKERFILE

    instructions = load_instructions(sys.argv[1])
    dockerfile = generate_dockerfile(create_context(sys.argv[1], instructions))
    with open(DOCKERFILE, "w") as df:
        df.write(dockerfile)
    print(instructions)
    print(dockerfile)