Compare commits

...

12 Commits

Author SHA1 Message Date
444f185fc5 Add support for versioned building from tasks 2025-03-19 22:43:19 +03:00
a670e7847c Add exclusion branches 'c10f2', 'c10f1' for image alt/distroless-toybox 2025-03-03 16:49:39 +03:00
c24ac6f89a Place python3 package first in the list
The first package in the list is used to form the image tag based
on the package version.
2025-02-24 17:06:29 +03:00
5c47e2296d Fix typo 2025-02-23 15:14:47 +03:00
34405300aa Add kmod and ipset to kube-proxy image for IPVS mode 2025-02-10 10:57:34 +03:00
7ee8840061 Add mount package to kubelet image
This is for closer resemblance with upstream kubernetes images.
2025-02-03 12:34:16 +03:00
a36a9d974e Add package nftables to kube-proxy image
This is for closer resemblance with upstream kubernetes images.
2025-02-03 12:34:16 +03:00
8ef16f6ea7 Make symlinks to /usr/local and use them as entrypoints
This is for closer resemblance with upstream kubernetes images.
2025-02-03 12:34:16 +03:00
6668dc4d6a fix building command in workflow 2025-01-14 22:51:30 +03:00
ae109e7adf delete exclusion building of distroless-devel from workflow 2025-01-14 22:44:10 +03:00
48a422a735 cut out base images for isolated building 2025-01-14 13:01:00 +03:00
efaa4b0aab add kubevirt images 2024-12-23 15:29:30 +03:00
68 changed files with 264 additions and 20 deletions

View File

@ -61,7 +61,7 @@ jobs:
- name: Run building script
id: build-script
run: |
build_args="-b $BR -o $ORG --skip-images alt/distroless-devel"
build_args="-b $BR --latest $BR -o $ORG --registry gitea.basealt.ru/alt"
if [[ "$BR" == "sisyphus" ]]; then arches="--arches amd64 386 arm64 loong64"; else arches="--arches amd64 386 arm64"; fi
if [[ "$ORG" == "k8s" ]]; then build_args="$build_args --overwrite-organization $ORG-$BR --package-versions {\"k8s/kube-apiserver\":\"1.31\",\"k8s/kube-scheduler\":\"1.31\",\"k8s/kube-controller-manager\":\"1.31\",\"k8s/kube-proxy\":\"1.31\",\"k8s/coredns\":\"1.11.3\",\"k8s/kubelet\":\"1.31\"}"; fi
echo "build.py $build_args $arches"

View File

@ -3,6 +3,7 @@
import argparse
import functools
import json
import logging
import re
import subprocess
import textwrap
@ -16,6 +17,8 @@ import tomli
import yaml
from jinja2 import Template
logger = logging.getLogger(__name__)
ORG_DIR = Path("org")
PKG_VERSIONS: dict | None = None
@ -25,7 +28,7 @@ PKG_VERSIONS: dict | None = None
class Image:
canonical_name: str
is_versioned: bool | None
verion_template: str | None
version_template: str | None
source_packages: list[str] | None
def __init__(self, canonical_name: str):
@ -114,6 +117,25 @@ def api_get_source_package_version(branch: str, package_name: str) -> str:
return result["versions"][0]["version"]
def api_get_source_package_version_from_task(task_id: str, package_name: str):
api_url = f"https://rdb.altlinux.org/api/task/packages/{task_id}"
response = requests.get(api_url)
if response.status_code != 200:
print(response)
raise RuntimeError(
f"failed to retrieve source package version from task: source package {package_name!r}, branch {branch!r}, task_id {task_id}"
)
result = response.json()
for subtask in result["subtasks"]:
if subtask["source"]["name"] == package_name:
return subtask["source"]["version"]
raise RuntimeError(
f"failed to retrieve source package version from task: source package {package_name!r}, branch {branch!r}, task_id {task_id}"
)
class Tags:
def __init__(self, tags_file: str | None, latest: str):
if tags_file is None:
@ -122,7 +144,7 @@ class Tags:
self._tags = tomli.loads(Path(tags_file).read_text())
self._latest = latest
def tags(self, branch: str, image: Image):
def tags(self, branch: str, image: Image, tasks: Tasks | None = None):
if self._tags is None:
if image.is_versioned is None:
tags = [branch]
@ -155,7 +177,28 @@ class Tags:
package_name = Template(package_name).render(
version=PKG_VERSIONS[image.canonical_name]
)
version = api_get_source_package_version(branch, package_name)
if tasks is not None:
task_ids = tasks.get(branch, image)
else:
task_ids = []
if task_ids:
logger.info(
"getting %s package version from task %s",
package_name,
task_ids[0],
)
version = api_get_source_package_version_from_task(
task_ids[0], package_name
)
else:
logger.info(
"getting %s package version from repo %s",
package_name,
branch,
)
version = api_get_source_package_version(branch, package_name)
if image.version_template is not None:
version = (
@ -652,7 +695,7 @@ class DockerBuilder:
self.images_info.skip_arches(image.canonical_name)
)
platforms = ",".join([f"linux/{a}" for a in build_arches])
tags = self.tags.tags(self.branch, image)
tags = self.tags.tags(self.branch, image, self.tasks)
manifest = self.render_full_tag(image, tags[0])
msg = "Building image {} for {} arches".format(
@ -712,7 +755,7 @@ class DockerBuilder:
if self.images_info.skip_branch(image.canonical_name, self.branch):
return
tags = self.tags.tags(self.branch, image)
tags = self.tags.tags(self.branch, image, self.tasks)
manifests = [self.render_full_tag(image, t) for t in tags]
for manifest in manifests:
@ -765,6 +808,8 @@ def parse_args():
images = [f"{o.name}/{i.name}" for o in organizations for i in o.iterdir()]
organizations = [o.name for o in organizations]
log_levels = ["debug", "info", "warning", "error", "critical"]
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
@ -875,6 +920,12 @@ def parse_args():
type=json.loads,
help="json string where key is image name, value is the package version",
)
parser.add_argument(
"--log-level",
default="warning",
choices=log_levels,
help="log messages above specified level",
)
args = parser.parse_args()
args.stages = set(args.stages) - set(args.skip_stages)
@ -890,6 +941,14 @@ def main():
args = parse_args()
PKG_VERSIONS = args.package_versions
numeric_level = getattr(logging, args.log_level.upper(), logging.WARNING)
logging.basicConfig(
level=numeric_level, format="%(asctime)s - %(levelname)s\t- %(message)s"
)
logger.info("PKG_VERSIONS=%s", PKG_VERSIONS)
arches = args.arches
images_info = ImagesInfo()
tags = Tags(args.tags, args.latest)

View File

@ -1,11 +1,11 @@
["alt/buildpack-deps"]
skip-branches = [ "p9" ]
["alt/distroless-toybox"]
skip-branches = [ "p10" ]
skip-branches = [ "p10", "c10f2", "c10f1" ]
["base/distroless-toybox"]
skip-branches = [ "p10", "c10f2", "c10f1" ]
["alt/openjdk21"]
skip-arches = [ "386" ]
["alt/ansible"]
skip-branches = [ "c10f2", "c10f1", "p10" ]
skip-branches = [ "c10f2", "c10f1", "p10" ]

View File

@ -10,6 +10,8 @@ LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("etcd") }}
RUN ln -s /usr/sbin/etcd /usr/local/bin/etcd
VOLUME /data
ENTRYPOINT ["/usr/sbin/etcd", "--data-dir", "/data"]

View File

@ -2,8 +2,8 @@
is_versioned: true
version_template: "{{ version }}"
source_packages:
- python3
- python3-module-setuptools
- python3-dev
- python3-module-pip
- gcc-defaults
...

View File

@ -2,7 +2,7 @@
is_versioned: true
version_template: "{{ version }}"
source_packages:
- python
- python-module-setuptools
- python-dev
- gcc-defaults
...

View File

@ -10,6 +10,8 @@ LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("etcd") }}
RUN ln -s /usr/sbin/etcd /usr/local/bin/etcd
VOLUME /data
ENTRYPOINT ["/usr/sbin/etcd", "--data-dir", "/data"]

View File

@ -6,7 +6,9 @@ ARG PKG_VERSION
{{ install_packages("kubernetes${PKG_VERSION}-master") }}
ENTRYPOINT ["/usr/bin/kube-apiserver"]
RUN ln -s /usr/bin/kube-apiserver /usr/local/bin/kube-apiserver
ENTRYPOINT ["/usr/local/bin/kube-apiserver"]
LABEL org.opencontainers.image.title="kube-apiserver"
LABEL org.opencontainers.image.description="The Kubernetes API server validates and configures data for the api objects which include pods, services, replicationcontrollers, and others."

View File

@ -6,7 +6,9 @@ ARG PKG_VERSION
{{ install_packages("kubernetes${PKG_VERSION}-master") }}
ENTRYPOINT ["/usr/bin/kube-controller-manager"]
RUN ln -s /usr/bin/kube-controller-manager /usr/local/bin/kube-controller-manager
ENTRYPOINT ["/usr/local/bin/kube-controller-manager"]
LABEL org.opencontainers.image.title="kube-controller-manager"
LABEL org.opencontainers.image.description="The Kubernetes controller manager is a daemon that embeds the core control loops shipped with Kubernetes."

View File

@ -4,11 +4,11 @@ MAINTAINER alt-cloud
ARG PKG_VERSION
{{ install_packages("kubernetes${PKG_VERSION}-node") }}
{{ install_packages("kmod", "ipset", "nftables", "kubernetes${PKG_VERSION}-node") }}
RUN ln -s /usr/bin/kube-proxy /usr/local/bin/kube-proxy
ENTRYPOINT ["/usr/bin/kube-proxy"]
ENTRYPOINT ["/usr/local/bin/kube-proxy"]
LABEL org.opencontainers.image.title="kube-proxy"
LABEL org.opencontainers.image.description="The Kubernetes network proxy runs on each node."

View File

@ -6,7 +6,9 @@ ARG PKG_VERSION
{{ install_packages("kubernetes${PKG_VERSION}-master") }}
ENTRYPOINT ["/usr/bin/kube-scheduler"]
RUN ln -s /usr/bin/kube-scheduler /usr/local/bin/kube-scheduler
ENTRYPOINT ["/usr/local/bin/kube-scheduler"]
LABEL org.opencontainers.image.title="kube-scheduler"
LABEL org.opencontainers.image.description="The Kubernetes scheduler is a control plane process which assigns Pods to Nodes."

View File

@ -4,11 +4,11 @@ MAINTAINER alt-cloud
ARG PKG_VERSION
{{ install_packages("ca-certificates", "ethtool", "socat", "kubernetes${PKG_VERSION}-kubelet") }}
{{ install_packages("ca-certificates", "ethtool", "socat", "mount", "kubernetes${PKG_VERSION}-kubelet") }}
RUN ln -s /usr/bin/kubelet /usr/local/bin/kubelet
ENTRYPOINT ["/usr/bin/kubelet"]
ENTRYPOINT ["/usr/local/bin/kubelet"]
LABEL org.opencontainers.image.title="kubelet" \
org.opencontainers.image.description="An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod." \

View File

@ -0,0 +1,16 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-api"
LABEL org.opencontainers.image.description="Kubevirt API server"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("kubevirt-virt-api") }}
RUN useradd -m -d /home/virt-api -u 10001 -s /bin/bash -c "virt-api user" virt-api
USER 10001
ENTRYPOINT ["/usr/bin/virt-api"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...

View File

@ -0,0 +1,16 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-controller"
LABEL org.opencontainers.image.description="Controller for kubevirt"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("kubevirt-virt-controller") }}
RUN useradd -m -d /home/virt-controller -u 10001 -s /bin/bash -c "virt-controller user" virt-controller
USER 10001
ENTRYPOINT ["/usr/bin/virt-controller"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...

View File

@ -0,0 +1,16 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-exportproxy"
LABEL org.opencontainers.image.description="Export proxy for kubevirt"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("kubevirt-virt-exportproxy") }}
RUN useradd -m -d /home/virt-exportproxy -u 10001 -s /bin/bash -c "virt-exportproxy user" virt-exportproxy
USER 10001
ENTRYPOINT ["/usr/bin/virt-exportproxy"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...

View File

@ -0,0 +1,16 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-exportserver"
LABEL org.ope:wncontainersncontainers.image.description="Export server for kubevirt"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("kubevirt-virt-exportserver") }}
RUN useradd -m -d /home/virt-exportserver -u 10001 -s /bin/bash -c "virt-exportserver user" virt-exportserver
USER 10001
ENTRYPOINT ["/usr/bin/virt-exportserver"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...

View File

@ -0,0 +1,21 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-handler"
LABEL org.opencontainers.image.description="Handler component for kubevirt"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
RUN groupadd -f -g 107 qemu > /dev/null 2>&1 ||:
RUN useradd -g qemu -m -d /home/qemu -s /bin/bash -c "qemu user" -u 107 qemu > /dev/null 2>&1 ||:
{{ install_packages(
"kubevirt-virt-handler",
"kubevirt-container-disk"
) }}
RUN cp -f /usr/share/kube-virt/virt-handler/nsswitch.conf /etc/ && cp -f /usr/share/kube-virt/virt-handler/virt_launcher.cil /
ENTRYPOINT ["/usr/bin/virt-handle"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...

View File

@ -0,0 +1,30 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-launcher"
LABEL org.opencontainers.image.description="Launcher component for kubevirt"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
RUN groupadd -f -g 107 qemu > /dev/null 2>&1 ||:
RUN useradd -g qemu -m -d /home/qemu -s /bin/bash -c "qemu user" -u 107 qemu > /dev/null 2>&1 ||:
{{ install_packages(
"kubevirt-virt-launcher",
"kubevirt-container-disk"
) }}
ENV DISPLAY=":0.0"
RUN export DISPLAY=":0.0"
RUN cp -f /usr/share/kube-virt/virt-launcher/virtqemud.conf /etc/libvirt/virtqemud.conf && cp -f /usr/share/kube-virt/virt-launcher/qemu.conf /etc/libvirt/qemu.conf
RUN VIRTIOFSD=$(rpm --eval '%{_libexecdir}')/virtiofsd; [ -d ${VIRTIOFSD} ] && VIRTIOFSD=${VIRTIOFSD}/virtiofsd; [ -f /usr/libexec/virtiofsd ] || (mkdir -p /usr/libexec && ln -svrt /usr/libexec ${VIRTIOFSD})
RUN setcap 'cap_net_bind_service=+ep' /usr/bin/virt-launcher && setcap 'cap_net_bind_service=+ep' /usr/bin/virt-launcher-monitor && setcap 'cap_net_bind_service=+ep' /usr/bin/qemu-system-$(uname -m) && chmod 0755 /etc/libvirt
RUN cd /var && rm -rf run && ln -s ../run .
ENTRYPOINT ["/usr/bin/virt-launcher-monitor"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...

View File

@ -0,0 +1,18 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="virt-operator"
LABEL org.opencontainers.image.description="Operator component for kubevirt"
LABEL org.opencontainers.image.source="https://github.com/kubevirt/kubevirt"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("kubevirt-virt-operator") }}
EXPOSE 8443 8444
RUN useradd -m -d /home/virt-operator -u 10001 -s /bin/bash -c "virt-operator user" virt-operator
USER 10001
ENTRYPOINT ["/usr/bin/virt-operator"]

View File

@ -0,0 +1,6 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kubevirt
...