Skip to content

Commit

Permalink
Added xpra ^Cd Xorg abilities - still WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Aloys Baillet <[email protected]>
  • Loading branch information
aloysbaillet committed Aug 19, 2020
1 parent 155bf1b commit 136fdf2
Show file tree
Hide file tree
Showing 9 changed files with 1,841 additions and 4 deletions.
27 changes: 26 additions & 1 deletion python/aswfdocker/cli/aswfdocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def packages():

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


@click.option(
"--sizes", "-s", is_flag=True, help="Display Sizes",
)
@cli.command()
def dockerstats(sizes):
"""Lists all known ci images in this format: IMAGEGROUP/IMAGE:VERSION
"""
if sizes:
total_size = 0
for org, image_type, image in utils.iter_all_images():
image_name = utils.get_image_name(image_type, image)
for tag, size in utils.get_image_sizes(org, image_name).items():
click.echo(f"{org}/{image_name}:{tag} size={size}")
total_size += size
click.echo(f"Total size={total_size}")
else:
total_pull = 0
for org, image_type, image in utils.iter_all_images():
image_name = utils.get_image_name(image_type, image)
pull_count = utils.get_image_pull_count(org, image_name)
click.echo(f"{org}/{image_name} pull_count={pull_count}")
total_pull += pull_count
click.echo(f"Total pull_count={total_pull}")


@cli.command()
@click.option(
"--settings-path", "-p", default="~/.aswfdocker", help="User settings file path.",
Expand Down
42 changes: 42 additions & 0 deletions python/aswfdocker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import subprocess
import datetime
import logging
import json
import urllib.request

from aswfdocker import constants

Expand Down Expand Up @@ -119,3 +121,43 @@ def get_group_from_image(image_type: constants.ImageType, image: str):
if img == image:
return group
raise RuntimeError(f"Cannot find group for image {image}")


def get_image_pull_count(docker_org, image):
url = f"https://hub.docker.com/v2/repositories/{docker_org}/{image}"
try:
d = json.loads(urllib.request.urlopen(url).read())
return d["pull_count"]
except urllib.error.HTTPError:
logger.debug("Failed to load data from URL %r", url)
return 0


def get_image_sizes(docker_org, image):
sizes = {}
url = f"https://hub.docker.com/v2/repositories/{docker_org}/{image}/tags/"
try:
d = json.loads(urllib.request.urlopen(url).read())
except urllib.error.HTTPError:
logger.debug("Failed to load data from URL %r", url)
return sizes
digests = set()
for tag in d["results"]:
digest = tag["images"][0]["digest"]
if digest in digests:
continue
digests.add(digest)
sizes[tag["name"]] = tag["full_size"]
return sizes


def iter_all_images():
for org in (constants.TESTING_DOCKER_ORG, constants.PUBLISH_DOCKER_ORG):
for image_type in (
constants.ImageType.PACKAGE,
constants.ImageType.CI_IMAGE,
constants.ImageType.RT_IMAGE,
):
for _, images in constants.GROUPS[image_type].items():
for image in images:
yield org, image_type, image
23 changes: 22 additions & 1 deletion rt-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ RUN yum install --setopt=tsflags=nodocs -y \
libXrender \
libXScrnSaver \
libxslt \
mesa-libGLU \
motif \
ncurses \
nss \
Expand All @@ -104,3 +103,25 @@ RUN yum install --setopt=tsflags=nodocs -y \
xorg-x11-server-Xvfb && \
rm -rf /var/cache/yum/*

RUN wget https://xpra.org/repos/CentOS/xpra.repo -P /etc/yum.repos.d/ && \
yum install --setopt=tsflags=nodocs -y xpra python-paramiko python-inotify python2-uinput && \
# Delete libGL installed by mesa... \
rm -f /usr/lib64/libGL.so* /usr/lib64/libGLdispatch.so* /usr/lib64/libGLX_system.so* /usr/lib64/libGLX_mesa* /usr/lib64/libGLX.so* && \
rm -rf /var/cache/yum/*

RUN wget https://sourceforge.net/projects/virtualgl/files/2.6.4/VirtualGL-2.6.4.x86_64.rpm/download -O /tmp/vgl.rpm && \
yum install -y /tmp/vgl.rpm && \
rm /tmp/vgl.rpm && \
rm -rf /var/cache/yum/*

RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
yum install -y dkms && \
rm -rf /var/cache/yum/*

COPY rt-base/xpra-entry-point.sh /usr/local/bin/
COPY rt-base/xpra.conf /etc/xpra/

ENV NVIDIA_DRIVER_CAPABILITIES=${NVIDIA_DRIVER_CAPABILITIES},display

# xpra default port
EXPOSE 14500
Loading

0 comments on commit 136fdf2

Please sign in to comment.