Skip to content

Commit 136fdf2

Browse files
committed
Added xpra ^Cd Xorg abilities - still WIP
Signed-off-by: Aloys Baillet <[email protected]>
1 parent 155bf1b commit 136fdf2

File tree

9 files changed

+1841
-4
lines changed

9 files changed

+1841
-4
lines changed

python/aswfdocker/cli/aswfdocker.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def packages():
257257

258258
@cli.command()
259259
def images():
260-
"""Lists all known ci images in this format: IMAGEGROUP/ci-CI_IMAGE:VERSION
260+
"""Lists all known ci images in this format: IMAGEGROUP/IMAGE:VERSION
261261
"""
262262
for image_type in (constants.ImageType.CI_IMAGE, constants.ImageType.RT_IMAGE):
263263
for group, images in constants.GROUPS[image_type].items():
@@ -267,6 +267,31 @@ def images():
267267
click.echo(f"{group}/{image_name}:{version}")
268268

269269

270+
@click.option(
271+
"--sizes", "-s", is_flag=True, help="Display Sizes",
272+
)
273+
@cli.command()
274+
def dockerstats(sizes):
275+
"""Lists all known ci images in this format: IMAGEGROUP/IMAGE:VERSION
276+
"""
277+
if sizes:
278+
total_size = 0
279+
for org, image_type, image in utils.iter_all_images():
280+
image_name = utils.get_image_name(image_type, image)
281+
for tag, size in utils.get_image_sizes(org, image_name).items():
282+
click.echo(f"{org}/{image_name}:{tag} size={size}")
283+
total_size += size
284+
click.echo(f"Total size={total_size}")
285+
else:
286+
total_pull = 0
287+
for org, image_type, image in utils.iter_all_images():
288+
image_name = utils.get_image_name(image_type, image)
289+
pull_count = utils.get_image_pull_count(org, image_name)
290+
click.echo(f"{org}/{image_name} pull_count={pull_count}")
291+
total_pull += pull_count
292+
click.echo(f"Total pull_count={total_pull}")
293+
294+
270295
@cli.command()
271296
@click.option(
272297
"--settings-path", "-p", default="~/.aswfdocker", help="User settings file path.",

python/aswfdocker/utils.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import subprocess
99
import datetime
1010
import logging
11+
import json
12+
import urllib.request
1113

1214
from aswfdocker import constants
1315

@@ -119,3 +121,43 @@ def get_group_from_image(image_type: constants.ImageType, image: str):
119121
if img == image:
120122
return group
121123
raise RuntimeError(f"Cannot find group for image {image}")
124+
125+
126+
def get_image_pull_count(docker_org, image):
127+
url = f"https://hub.docker.com/v2/repositories/{docker_org}/{image}"
128+
try:
129+
d = json.loads(urllib.request.urlopen(url).read())
130+
return d["pull_count"]
131+
except urllib.error.HTTPError:
132+
logger.debug("Failed to load data from URL %r", url)
133+
return 0
134+
135+
136+
def get_image_sizes(docker_org, image):
137+
sizes = {}
138+
url = f"https://hub.docker.com/v2/repositories/{docker_org}/{image}/tags/"
139+
try:
140+
d = json.loads(urllib.request.urlopen(url).read())
141+
except urllib.error.HTTPError:
142+
logger.debug("Failed to load data from URL %r", url)
143+
return sizes
144+
digests = set()
145+
for tag in d["results"]:
146+
digest = tag["images"][0]["digest"]
147+
if digest in digests:
148+
continue
149+
digests.add(digest)
150+
sizes[tag["name"]] = tag["full_size"]
151+
return sizes
152+
153+
154+
def iter_all_images():
155+
for org in (constants.TESTING_DOCKER_ORG, constants.PUBLISH_DOCKER_ORG):
156+
for image_type in (
157+
constants.ImageType.PACKAGE,
158+
constants.ImageType.CI_IMAGE,
159+
constants.ImageType.RT_IMAGE,
160+
):
161+
for _, images in constants.GROUPS[image_type].items():
162+
for image in images:
163+
yield org, image_type, image

rt-base/Dockerfile

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ RUN yum install --setopt=tsflags=nodocs -y \
8080
libXrender \
8181
libXScrnSaver \
8282
libxslt \
83-
mesa-libGLU \
8483
motif \
8584
ncurses \
8685
nss \
@@ -104,3 +103,25 @@ RUN yum install --setopt=tsflags=nodocs -y \
104103
xorg-x11-server-Xvfb && \
105104
rm -rf /var/cache/yum/*
106105

106+
RUN wget https://xpra.org/repos/CentOS/xpra.repo -P /etc/yum.repos.d/ && \
107+
yum install --setopt=tsflags=nodocs -y xpra python-paramiko python-inotify python2-uinput && \
108+
# Delete libGL installed by mesa... \
109+
rm -f /usr/lib64/libGL.so* /usr/lib64/libGLdispatch.so* /usr/lib64/libGLX_system.so* /usr/lib64/libGLX_mesa* /usr/lib64/libGLX.so* && \
110+
rm -rf /var/cache/yum/*
111+
112+
RUN wget https://sourceforge.net/projects/virtualgl/files/2.6.4/VirtualGL-2.6.4.x86_64.rpm/download -O /tmp/vgl.rpm && \
113+
yum install -y /tmp/vgl.rpm && \
114+
rm /tmp/vgl.rpm && \
115+
rm -rf /var/cache/yum/*
116+
117+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
118+
yum install -y dkms && \
119+
rm -rf /var/cache/yum/*
120+
121+
COPY rt-base/xpra-entry-point.sh /usr/local/bin/
122+
COPY rt-base/xpra.conf /etc/xpra/
123+
124+
ENV NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES},display
125+
126+
# xpra default port
127+
EXPOSE 14500

0 commit comments

Comments
 (0)