python-sfml icon indicating copy to clipboard operation
python-sfml copied to clipboard

Launching app from docker container

Open iago-lito opened this issue 8 years ago • 1 comments

I am trying to wrap my pysfml app within a docker image, because it would be amazing for prototypes distribution. Let's test it with the official pong.py example.

Here is the folder I build the image from:

Dockerfile
pong.py
data/
    ball.wav
    sansation.ttf

Here is the Dockerfile:

FROM library/debian:stretch

# create a dummy group-and-user
RUN addgroup --system pong              \
    && adduser                          \
        --home /home/moby               \
        --disabled-password             \
        --shell /bin/bash               \
        --gecos "user for running pong" \
        --ingroup pong                  \
        --quiet                         \
        moby

# install graphics support and pysfml (+ a jacknife)
RUN apt-get -y update && apt-get install -y mesa-utils python3-sfml nano

USER moby

# basic pong example
WORKDIR /home/moby
COPY ./ ./

I build the image with:

docker build -t hello-sfml .

I run the container with:

docker run -ti --rm    \       
   -e DISPLAY=$DISPLAY \
   -v /tmp/.X11-unix:/tmp/.X11-unix hello-sfml /bin/bash

from within the container, I launch the app with:

python3 pong.py

Pong starts correctly and I can play. But here is a first naughty output:

libGL error: MESA-LOADER: failed to retrieve device information
libGL error: Version 4 or later of flush extension not found
libGL error: failed to load driver: i915
libGL error: failed to open drm device: No such file or directory
libGL error: failed to load driver: i965
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4850:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4371:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4850:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2450:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory

Accordingly, I have no sound, which is the first bug. How to get alsa working?

Clue: sound works well if I add RUN apt-get update && apt-get -y install vlc to the Dockerfile, and I get no ALSA warnings. But I guess thin is a bit too much to get pysfml sound working, right? What is the least I should add?

As a second --- way more severe --- bug: the app crashes as soon as I use the mouse scrool wheel button, here is the traceback:

Traceback (most recent call last):
  File "pong.py", line 72, in <module>
    for event in window.events:
  File "src/sfml/window.pyx", line 797, in events_generator (src/sfml/window.cpp:14768)
  File "src/sfml/window.pyx", line 161, in sfml.window.wrap_event (src/sfml/window.cpp:3324)
UnboundLocalError: local variable 'event' referenced before assignment

.. accordingly, I cannot use the scroll button in my actual apps from a container or they will crash.. which is bad :(

Clue: mouse button does work in the container, since it works if I launch vlc from inside it and use it to, say, decrease the volume. So I guess that everything is good with mouse hardware, drivers etc.

How do I get pysfml fully working from a docker container?

iago-lito avatar Jan 06 '17 16:01 iago-lito

I'm not familiar with container technologies. Can't help you...

However, I appreciate your contribution, perhaps edit wiki with recipe ?

intjelic avatar Mar 03 '17 20:03 intjelic