def update_base_images(): versions = get_versions() for package in versions["base"]: current = versions["base"][package] new = get_docker_tags(package) if current != new: versions = get_versions() print(f"Updating {package} from {current} to {new}") versions["base"][package] = new save_versions(versions)
def update_python_packages(): versions = get_versions() for package in versions["python"]: current = versions["python"][package] new = get_version_pypi(package) if current != new: versions = get_versions() print(f"Updating {package} from {current} to {new}") versions["python"][package] = new save_versions(versions)
def update_alpine_packages(): versions = get_versions() alpine = f"v{versions['base']['alpine'][:-2]}" for package in versions["alpine"]: current = versions["alpine"][package] new = sorted(get_package(package, alpine)["versions"]).pop() if current != new: versions = get_versions() print(f"Updating {package} from {current} to {new}") versions["alpine"][package] = new save_versions(versions)
def update_s6(): installfile = "rootfs/s6/install" current = get_release_from_github("just-containers/s6-overlay") with open(installfile, "r") as install: content = install.read() installed = content.split('="')[1].split('"\n')[0] if current != installed: content = content.replace(installed, current) with open(installfile, "w") as install: install.write(content) versions = get_versions() versions["special"]["S6"] = current save_versions(versions)
import json from ruamel.yaml import YAML from scripts.helpers.files import get_instruction_files, get_versions from scripts.helpers.set_properties import set_envs, set_labels, set_versions versions = get_versions() yamlloader = YAML() def load_instructions(container): _all = {} _bases = [] _container = {} for f in [ x for x in get_instruction_files() if x.startswith("./instructions/") ]: with open(f) as file: tag = f.split("/")[-1].replace(".yaml", "") if _all.get(tag) is not None: print(f"Multiple files for tag ({tag}) found!") exit(1) _all[f.split("/")[-1].replace(".yaml", "")] = yamlloader.load(file) if _all[container]["base"] not in versions["base"]: _bases.append(_all[container]["base"]) while True: base = _all[_bases[-1]]["base"] if base in versions["base"]: break
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))
def update_netcore(version): baseurl = "https://dotnet.microsoft.com" dotnet = { "arm": { "sdk": None, "runtime": None }, "arm64": { "sdk": None, "runtime": None }, "amd64": { "sdk": None, "runtime": None }, } url = f"{baseurl}/download/dotnet-core/{version}" request = requests.get(url).text for line in request.split("\n"): if ("ARM32" in line and "linux" in line and "sdk" in line and dotnet["arm"]["sdk"] is None): dotnet["arm"]["sdk"] = line.split('"')[1] if ("ARM32" in line and "linux" in line and "runtime" in line and dotnet["arm"]["runtime"] is None and "aspnetcore" not in line): dotnet["arm"]["runtime"] = line.split('"')[1] if ("ARM64" in line and "linux" in line and "sdk" in line and dotnet["arm64"]["sdk"] is None): dotnet["arm64"]["sdk"] = line.split('"')[1] if ("ARM64" in line and "linux" in line and "runtime" in line and dotnet["arm64"]["runtime"] is None and "aspnetcore" not in line): dotnet["arm64"]["runtime"] = line.split('"')[1] if ("x64" in line and "rhel" not in line and "alpine" not in line and "linux" in line and "sdk" in line and dotnet["amd64"]["sdk"] is None and "aspnetcore" not in line): dotnet["amd64"]["sdk"] = line.split('"')[1] if ("x64" in line and "rhel" not in line and "alpine" not in line and "linux" in line and "runtime" in line and dotnet["amd64"]["runtime"] is None): dotnet["amd64"]["runtime"] = line.split('"')[1] for arch in dotnet: if dotnet[arch]["sdk"] is None or dotnet[arch]["runtime"] is None: continue request = requests.get(f"{baseurl}{dotnet[arch]['sdk']}").text for line in request.split("\n"): if "window.open" in line: dotnet[arch]["sdk"] = line.split('"')[1] break request = requests.get(f"{baseurl}{dotnet[arch]['runtime']}").text for line in request.split("\n"): if "window.open" in line: dotnet[arch]["runtime"] = line.split('"')[1] break path = "rootfs/dotnet-base/build_scripts/install" if version == "5.0": path = "rootfs/dotnet5-base/build_scripts/install" with open( path, "r", ) as dnfile: content = dnfile.read() newcontent = f"""#!/bin/bash # https://dotnet.microsoft.com/download/dotnet-core/{version} ARCH=$(uname -m) if [ "$ARCH" == "armv7l" ]; then wget -q -nv -O /tmp/runtime.tar.gz "{dotnet["arm"]["runtime"]}"; wget -q -nv -O /tmp/sdk.tar.gz "{dotnet["arm"]["sdk"]}"; elif [ "$ARCH" == "aarch64" ]; then wget -q -nv -O /tmp/runtime.tar.gz "{dotnet["arm64"]["runtime"]}"; wget -q -nv -O /tmp/sdk.tar.gz "{dotnet["arm64"]["sdk"]}"; elif [ "$ARCH" == "x86_64" ]; then wget -q -nv -O /tmp/runtime.tar.gz "{dotnet["amd64"]["runtime"]}"; wget -q -nv -O /tmp/sdk.tar.gz "{dotnet["amd64"]["sdk"]}"; fi """ if newcontent != content: with open(path, "w") as dnfile: dnfile.write(newcontent) versions = get_versions() if version == "5.0": versions["special"]["dotnetcore5-runtime"] = ( dotnet["arm64"]["runtime"].split("-runtime-")[1].split( "-linux")[0]) versions["special"]["dotnetcore5-sdk"] = ( dotnet["arm64"]["sdk"].split("-sdk-")[1].split("-linux")[0]) else: versions["special"]["dotnetcore-runtime"] = ( dotnet["arm64"]["runtime"].split("-runtime-")[1].split( "-linux")[0]) versions["special"]["dotnetcore-sdk"] = ( dotnet["arm64"]["sdk"].split("-sdk-")[1].split("-linux")[0]) save_versions(versions)