9 Commits

Author SHA1 Message Date
fc2a686fc1 feat(build.py): clean images only if specified through cli option 2025-07-30 16:43:27 +03:00
fccd2998fe feat(build.py): get package version from repo if couldn't from task 2025-07-30 16:43:27 +03:00
bc457107f1 fix(build.py): use identity check instead of equality for None 2025-07-30 16:43:27 +03:00
81d5297c7c style: remove trailing whitespace 2025-07-30 16:43:27 +03:00
ebfa49dd1d fix(org/alt): delete config volumes from kafka and redis
All checks were successful
Building alt images / build-process (push) Successful in 3m56s
Building alt images / test-process (push) Successful in 1m10s
2025-07-23 12:47:50 +03:00
d609016659 fix(images-info.toml): Add skip-arches for kafka image
Some checks failed
Building alt images / build-process (push) Successful in 5m9s
Building alt images / test-process (push) Failing after 1m17s
2025-07-23 11:58:13 +03:00
a3de7f8261 fix(images-info.toml): Add skip-arches for kubevirt images
Some checks failed
Full building alt images / build-process (push) Successful in 16m15s
Full building alt images / test-process (push) Successful in 1m10s
Building alt images / build-process (push) Successful in 5m11s
Building alt images / test-process (push) Failing after 1m16s
2025-07-22 13:39:34 +03:00
0a105aace4 Add kafka image
All checks were successful
Full building alt images / build-process (push) Successful in 4m34s
Full building alt images / test-process (push) Has been skipped
2025-07-22 11:42:41 +03:00
2db6b03aa8 Add redis image 2025-07-22 11:39:29 +03:00
13 changed files with 219 additions and 27 deletions

View File

@ -19,8 +19,6 @@ import yaml
from jinja2 import Environment, BaseLoader
logger = logging.getLogger(__name__)
clean_images_counter = 0
clean_images_limit_count = 5
ORG_DIR = Path("org")
@ -103,6 +101,8 @@ class Tasks:
if image.canonical_name in i or len(i) == 0
]
class AltAPIError(Exception):
pass
def api_get_source_package_version(branch: str, package_name: str) -> str:
api_url = "https://rdb.altlinux.org/api/site/package_versions_from_tasks"
@ -113,7 +113,7 @@ def api_get_source_package_version(branch: str, package_name: str) -> str:
params = {"arch": "x86_64", "package_type": "source", "name": package_name}
response = requests.get(api_url, params)
if response.status_code != 200:
raise RuntimeError(
raise AltAPIError(
f"failed to retrieve source package version: source package {package_name!r}, branch {branch!r} "
)
result = response.json()
@ -121,7 +121,7 @@ def api_get_source_package_version(branch: str, package_name: str) -> str:
if v["branch"] == branch:
return v["version"]
raise RuntimeError(
raise AltAPIError(
f"failed to retrieve source package version: source package {package_name!r}, branch {branch!r} "
)
@ -134,7 +134,7 @@ 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:
raise RuntimeError(
raise AltAPIError(
f"failed to retrieve source package version from task: source package {package_name!r}, task_id {task_id}"
)
@ -143,7 +143,7 @@ def api_get_source_package_version_from_task(task_id: str, package_name: str):
if subtask["source"]["name"] == package_name:
return subtask["source"]["version"]
raise RuntimeError(
raise AltAPIError(
f"failed to retrieve source package version from task: source package {package_name!r}, task_id {task_id}"
)
@ -202,9 +202,22 @@ class Tags:
package_name,
task_ids[0],
)
version = api_get_source_package_version_from_task(
task_ids[0], package_name
)
try:
version = api_get_source_package_version_from_task(
task_ids[0], package_name
)
except AltAPIError:
logger.warning(
"failed getting %s package version from task %s",
package_name,
task_ids[0],
)
logger.info(
"getting %s package version from repo %s",
package_name,
branch,
)
version = api_get_source_package_version(branch, package_name)
else:
logger.info(
"getting %s package version from repo %s",
@ -772,7 +785,7 @@ class DockerBuilder:
".",
]
if image.annotations != None:
if image.annotations is not None:
build_cmd = [
"podman",
"build",
@ -829,23 +842,6 @@ class DockerBuilder:
self.run(cmd)
global clean_images_counter
if clean_images_limit_count <= clean_images_counter:
cmd = [
"podman",
"rmi",
"--all",
"-f",
]
self.run(cmd,
check=False,
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
)
clean_images_counter = 0
else:
clean_images_counter += 1
class ImagesInfo:
@ -994,6 +990,10 @@ def parse_args():
type=json.loads,
help="json string where key is image name, value is the package version",
)
parser.add_argument(
"--clean-images-limit",
help="remove all the images in the container storage when number of images hits the limit",
)
parser.add_argument(
"--log-level",
default="warning",
@ -1023,6 +1023,8 @@ def main():
logger.info("PKG_VERSIONS=%s", PKG_VERSIONS)
clean_images_counter = 0
arches = args.arches
images_info = ImagesInfo()
tags = Tags(args.tags, args.latest)
@ -1044,6 +1046,7 @@ def main():
if "render_dockerfiles" in args.stages:
db.render_dockerfiles()
db.load_distrolesses()
for image in db.get_build_order():
if image.canonical_name not in args.images:
continue
@ -1057,6 +1060,23 @@ def main():
if "push" in args.stages:
db.podman_push(image, args.sign)
if args.clean_images_limit is not None:
if clean_images_counter >= args.clean_images_limit:
cmd = [
"podman",
"rmi",
"--all",
"-f",
]
db.run(cmd,
check=False,
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
)
clean_images_counter = 0
else:
clean_images_counter += 1
if __name__ == "__main__":
main()

View File

@ -7,8 +7,32 @@ skip-arches = [ "386" ]
["alt/zot"]
skip-arches = [ "386" ]
["alt/kafka"]
skip-arches = [ "386" ]
["alt/ansible"]
skip-branches = [ "c10f2", "c10f1", "p10" ]
["alt/buildkit"]
skip-branches = [ "c10f1", "p10" ]
["kubevirt/virt-api"]
skip-arches = [ "386", "loong64" ]
["kubevirt/virt-controller"]
skip-arches = [ "386", "loong64" ]
["kubevirt/virt-exportproxy"]
skip-arches = [ "386", "loong64" ]
["kubevirt/virt-exportserver"]
skip-arches = [ "386", "loong64" ]
["kubevirt/virt-handler"]
skip-arches = [ "386", "loong64" ]
["kubevirt/virt-launcher"]
skip-arches = [ "386", "loong64" ]
["kubevirt/virt-operator"]
skip-arches = [ "386", "loong64" ]

View File

@ -0,0 +1,21 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="kafka"
LABEL org.opencontainers.image.description="Apache Kafka is a distributed event store and stream-processing platform"
LABEL org.opencontainers.image.source="https://github.com/apache/kafka"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("kafka", "ca-certificates", "gpg") }}
USER kafka:kafka
EXPOSE 9092 2181
WORKDIR /var/lib/kafka
VOLUME ["/var/lib/kafka","/var/log/kafka"]
COPY kafka-entrypoint.sh /kafka-entrypoint.sh
ENTRYPOINT [ "/bin/bash" ]
CMD ["/kafka-entrypoint.sh"]

37
org/alt/kafka/README.md Normal file
View File

@ -0,0 +1,37 @@
# Kafka image
Command for run kafka server:
```
podman run --rm -it -p 9092:9092 <REGISTRY>/<BRANCH>/kafka:latest
```
To lead images running need use kafka-entrypoint.sh or change it. As default login kafka need runnig zookeeper and than kafka's start script.
Commnad for using kafka:
```
podman exec -it -u kafka <CONTAINER ID> /usr/bin/sh
```
```
sh-5.2$ /usr/lib/kafka/bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092
```
Created topic quickstart-events.
```
sh-5.2$ /usr/lib/kafka/bin/kafka-topics.sh --describe --topic quickstart-events --bootstrap-server localhost:9092
```
Topic: quickstart-events TopicId: kPjhCFFAS-Sg5J3Hpgr-PA PartitionCount: 1 ReplicationFactor: 1 Configs:
Topic: quickstart-events Partition: 0 Leader: 0 Replicas: 0 Isr: 0 Elr: N/A LastKnownElr: N/A
```
sh-5.2$ /usr/lib/kafka/bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092
```
>hello 1
>hello 2
>hello 3
```
sh-5.2$ /usr/lib/kafka/bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092
```
hello 1
hello 2
hello 3
^CProcessed a total of 3 messages

15
org/alt/kafka/info.yaml Normal file
View File

@ -0,0 +1,15 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- kafka
annotations:
org.opencontainers.image.revision: ''
org.opencontainers.image.source: 'https://github.com/apache/kafka'
org.opencontainers.image.url: ''
org.opencontainers.image.version: ''
org.opencontainers.image.title: 'kafka'
org.opencontainers.image.description: 'Apache Kafka is a distributed event store and stream-processing platform'
org.opencontainers.image.licenses: Apache-2.0
org.opencontainers.image.vendor: 'ALT Linux Team'
...

View File

@ -0,0 +1,4 @@
#!/bin/sh -eux
nohup /usr/lib/kafka/bin/zookeeper-server-start.sh /etc/kafka/zookeeper.properties &
/usr/lib/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties

1
org/alt/kafka/test Normal file
View File

@ -0,0 +1 @@
ls -a /usr/lib/kafka/bin/ | grep kafka && /usr/lib/kafka/bin/kafka-topics.sh --version

View File

@ -0,0 +1,19 @@
FROM {{ registry }}{{ branch }}/{{ alt_image }}:latest
MAINTAINER alt-cloud
LABEL org.opencontainers.image.title="redis"
LABEL org.opencontainers.image.description="Redis is an advanced key-value store"
LABEL org.opencontainers.image.source="http://redis.io"
LABEL org.opencontainers.image.licenses="BSD-3-Clause AND BSD-2-Clause AND MIT AND BSL-1.0"
LABEL org.opencontainers.image.vendor="ALT Linux Team"
{{ install_packages("ca-certificates","redis","redis-cli") }}
USER _redis:_redis
EXPOSE 6379
VOLUME ["/var/lib/redis","/var/log/redis"]
WORKDIR /var/lib/redis
ENTRYPOINT [ "/usr/sbin/redis-server" ]
CMD [ "/etc/redis/redis.conf" ]

8
org/alt/redis/README.md Normal file
View File

@ -0,0 +1,8 @@
# Redis image
Command for run redis-db server:
```
podman run --rm -it -v ./redis.conf:/etc/redis/redis.conf -p 6379:6379 <REGISTRY>/<BRANCH>/redis:latest
```
For testing running server you can run redis.py, if it's working you will see version redis

15
org/alt/redis/info.yaml Normal file
View File

@ -0,0 +1,15 @@
---
is_versioned: true
version_template: "{{ version }}"
source_packages:
- redis
annotations:
org.opencontainers.image.revision: ''
org.opencontainers.image.source: 'http://redis.io/'
org.opencontainers.image.url: ''
org.opencontainers.image.version: ''
org.opencontainers.image.title: 'redis'
org.opencontainers.image.description: 'Redis is an advanced key-value store'
org.opencontainers.image.licenses: 'BSD-3-Clause AND BSD-2-Clause AND MIT AND BSL-1.0'
org.opencontainers.image.vendor: 'ALT Linux Team'
...

22
org/alt/redis/redis.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/python3
import redis
def main():
r = redis.Redis(host='127.0.0.1', port=6379, db=0, username='test', password='test')
try:
info = r.info()
print(info['redis_version'])
response = r.ping()
if response:
print("Подключение успешно!")
else:
print("Не удалось подключиться к Redis.")
except redis.exceptions.RedisError as e:
print(f"Ошибка: {e}")
if __name__ == "__main__":
main()

1
org/alt/redis/test Normal file
View File

@ -0,0 +1 @@
redis-cli --version && redis-server --version

View File

@ -0,0 +1,5 @@
bind 0.0.0.0
requirepass test
appendonly yes
appendfsync everysec
user test on -DEBUG +@all ~* >test