Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update docker #325

Merged
merged 9 commits into from
Oct 28, 2022
Merged

update docker #325

merged 9 commits into from
Oct 28, 2022

Conversation

ReenigneArcher
Copy link
Member

@ReenigneArcher ReenigneArcher commented Aug 11, 2022

Description

  • Add sunshine docker image

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the docstring/documentation-blocks for new or existing methods/components

@ReenigneArcher ReenigneArcher force-pushed the update/docker branch 12 times, most recently from 1e44b40 to 9b91da1 Compare August 11, 2022 23:14
@ReenigneArcher ReenigneArcher force-pushed the update/docker branch 5 times, most recently from bd41c84 to 81430bd Compare August 12, 2022 00:42
@ReenigneArcher ReenigneArcher mentioned this pull request Aug 12, 2022
7 tasks
@ReenigneArcher ReenigneArcher marked this pull request as ready for review August 12, 2022 02:13
@ReenigneArcher
Copy link
Member Author

@ABeltramo could you please review this PR when you have time? Most importantly, the Dockerfile and DOCKER_README.md. Let me know if I need to add anything in order for this to be usable for GOW.

@ABeltramo
Copy link
Collaborator

I encountered a few issues by checking this out on my local machine, I'll present them in order:

Docker build failed

I started by trying to build the image and this error was returned: mkdir unable to create folder /root/sunshine-build/build.
This is because I'm also building via cmake in the same folder so the build/ folder was already present and it'll be COPY-ed over when doing COPY . ..

My suggestion is to add a .dockerignore file with the stuff that shouldn't be copied, ex:

build
.github
tools
docs

This will also avoid invalidating the cache when changing stuff that's not going into the container anyway.

TZ, PUID and PGID aren't mapped

While you specified them as part of possible environment variables they aren't mapped to anything in the dockerfile. Docker doesn't take care of them automagically (unfortunately).

If you set them as ARG like ARG TZ="America/New_York" this can be changed only during build time but once an image has been built they are written in stone.

The correct way is to set them as ENV and then, in order to properly set this stuff up, you'll have to add a bash script on startup that creates the user with the correct PUID, PGID and changes the timezone to what the user passed at runtime.

Running the container doesn't work

After building the docker image I tried to run it but I've got the following error:

unable to start container process: exec: "/usr/bin/sunshine": stat /usr/bin/sunshine: no such file or directory: unknown.

Let's see what's in the docker image then:

docker run -it --rm --name=sunshine --net=host --entrypoint /bin/bash lizardbyte/sunshine:local

ls /usr/bin/sunshine
ls: cannot access '/usr/bin/sunshine': No such file or directory

ls -la /config/
total 8
drwxr-xr-x 2 root root 4096 Aug 12 07:46 .
drwxr-xr-x 1 root root 4096 Aug 12 08:05 ..

ls /sunshine.deb
/sunshine.deb

dpkg-deb -I /sunshine.deb
 new Debian package, version 2.0.
 size 3170778 bytes: control archive=2586 bytes.
      78 bytes,     2 lines      conffiles            
     631 bytes,    12 lines      control              
    4631 bytes,    51 lines      md5sums              
    1232 bytes,    41 lines      postinst             #!/bin/sh
     385 bytes,     9 lines      preinst              #!/bin/sh
 Architecture: amd64
 Depends: openssl, libavdevice58, libboost-thread1.67.0 | libboost-thread1.71.0 | libboost-thread1.74.0, libboost-filesystem1.67.0 | libboost-filesystem1.71.0 | libboost-filesystem1.74.0, libboost-log1.67.0 | libboost-log1.71.0 | libboost-log1.74.0, libpulse0, libopus0, libxcb-shm0, libxcb-xfixes0, libxtst6, libevdev2, libdrm2, libcap2
 Description: Sunshine is a Gamestream host for Moonlight.
  Sunshine is a Gamestream host for Moonlight.
 Homepage: https://app.lizardbyte.dev
 Maintainer: https://github.com/LizardByte
 Package: sunshine
 Priority: optional
 Section: devel
 Version: 0.14.1
 Installed-Size: 12739

dpkg-deb -c /sunshine.deb
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/bin/
lrwxrwxrwx root/root         0 2022-08-12 07:46 ./etc/bin/sunshine -> sunshine-0.14.1
-rwxr-xr-x root/root   4548680 2022-08-12 07:46 ./etc/bin/sunshine-0.14.1
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/lib/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/lib/systemd/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/lib/systemd/user/
-rw-r--r-- root/root       148 2022-08-12 07:45 ./etc/lib/systemd/user/sunshine.service
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/lib/udev/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/lib/udev/rules.d/
-rw-r--r-- root/root        75 2022-08-12 07:37 ./etc/lib/udev/rules.d/85-sunshine.rules
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/
-rw-r--r-- root/root       998 2022-08-12 07:37 ./etc/sunshine/assets/box.png
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/shaders/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/shaders/opengl/
-rw-r--r-- root/root       855 2022-08-12 07:37 ./etc/sunshine/assets/shaders/opengl/ConvertUV.frag
-rw-r--r-- root/root       620 2022-08-12 07:37 ./etc/sunshine/assets/shaders/opengl/ConvertUV.vert
-rw-r--r-- root/root       399 2022-08-12 07:37 ./etc/sunshine/assets/shaders/opengl/ConvertY.frag
-rw-r--r-- root/root       181 2022-08-12 07:37 ./etc/sunshine/assets/shaders/opengl/Scene.frag
-rw-r--r-- root/root       347 2022-08-12 07:37 ./etc/sunshine/assets/shaders/opengl/Scene.vert
-rw-r--r-- root/root     25012 2022-08-12 07:37 ./etc/sunshine/assets/steam.png
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/
-rw-r--r-- root/root      8177 2022-08-12 07:37 ./etc/sunshine/assets/web/apps.html
-rw-r--r-- root/root        63 2022-08-12 07:37 ./etc/sunshine/assets/web/clients.html
-rw-r--r-- root/root     33037 2022-08-12 07:37 ./etc/sunshine/assets/web/config.html
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/fonts/
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/
-rw-r--r-- root/root      1548 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/LICENSE.txt
-rw-r--r-- root/root       187 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/attribution.js
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/
-rw-r--r-- root/root     59305 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/all.min.css
-rw-r--r-- root/root       675 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/brands.min.css
-rw-r--r-- root/root     57873 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/fontawesome.min.css
-rw-r--r-- root/root       677 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/regular.min.css
-rw-r--r-- root/root       669 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/solid.min.css
-rw-r--r-- root/root      6359 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/svg-with-js.min.css
-rw-r--r-- root/root     26702 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/css/v4-shims.min.css
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/
-rw-r--r-- root/root    134294 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-brands-400.eot
-rw-r--r-- root/root    747927 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-brands-400.svg
-rw-r--r-- root/root    133988 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-brands-400.ttf
-rw-r--r-- root/root     89988 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-brands-400.woff
-rw-r--r-- root/root     76736 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-brands-400.woff2
-rw-r--r-- root/root     34034 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-regular-400.eot
-rw-r--r-- root/root    144714 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-regular-400.svg
-rw-r--r-- root/root     33736 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-regular-400.ttf
-rw-r--r-- root/root     16276 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-regular-400.woff
-rw-r--r-- root/root     13224 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-regular-400.woff2
-rw-r--r-- root/root    203030 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-solid-900.eot
-rw-r--r-- root/root    918991 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-solid-900.svg
-rw-r--r-- root/root    202744 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-solid-900.ttf
-rw-r--r-- root/root    101648 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-solid-900.woff
-rw-r--r-- root/root     78268 2022-08-12 07:37 ./etc/sunshine/assets/web/fonts/fontawesome-free-web/webfonts/fa-solid-900.woff2
-rw-r--r-- root/root       452 2022-08-12 07:37 ./etc/sunshine/assets/web/header-no-nav.html
-rw-r--r-- root/root      2762 2022-08-12 07:37 ./etc/sunshine/assets/web/header.html
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/images/
-rw-r--r-- root/root    120760 2022-08-12 07:37 ./etc/sunshine/assets/web/images/favicon.ico
-rw-r--r-- root/root      2115 2022-08-12 07:37 ./etc/sunshine/assets/web/images/logo-sunshine-45.png
-rw-r--r-- root/root      1546 2022-08-12 07:37 ./etc/sunshine/assets/web/index.html
-rw-r--r-- root/root      3636 2022-08-12 07:37 ./etc/sunshine/assets/web/password.html
-rw-r--r-- root/root      1525 2022-08-12 07:37 ./etc/sunshine/assets/web/pin.html
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/assets/web/third_party/
-rw-r--r-- root/root     79665 2022-08-12 07:37 ./etc/sunshine/assets/web/third_party/bootstrap.bundle.min.js
-rw-r--r-- root/root    155567 2022-08-12 07:37 ./etc/sunshine/assets/web/third_party/bootstrap.min.css
-rw-r--r-- root/root    342147 2022-08-12 07:37 ./etc/sunshine/assets/web/third_party/vue.js
-rw-r--r-- root/root      2454 2022-08-12 07:37 ./etc/sunshine/assets/web/troubleshooting.html
-rw-r--r-- root/root      2855 2022-08-12 07:37 ./etc/sunshine/assets/web/welcome.html
drwxr-xr-x root/root         0 2022-08-12 07:46 ./etc/sunshine/config/
-rw-r--r-- root/root       377 2022-08-12 07:37 ./etc/sunshine/config/apps.json
-rw-r--r-- root/root        73 2022-08-12 07:37 ./etc/sunshine/config/sunshine.conf

Found it! It looks like Sunshine is installed at /etc/bin/sunshine. I'm not sure here what's the latest on the cpack you can either change the ENTRYPOINT or change the install path with some cmake variable if you have one.

Let's run it!

I've changed the entrypoint, rebuilt and run:

docker run -it --rm --name=sunshine --net=host  lizardbyte/sunshine:local

Nothing happens, no log message, no output. The process is stuck there eating CPU at 100% but worst of all allocating memory like crazy!

Screenshot 2022-08-12 at 09 19 56

(it keeps growing, here at ~6.5GB of RAM used I forcefully killed the container).

I don't know what the issue is but this seems pretty bad.

Final comments

There are a few things missing in this Dockerfile compared to the Dockerfile on GOW most notably:

  • you haven't installed any additional libraries when installing the .deb
  • using --no-install-recommends when installing sunshine.deb might have created an environment that is missing some required library.

Even assuming that the final container is in a good state the instructions in the DOCKER_README aren't really sufficient to run Sunshine. You'll have to pass the Xorg/Wayland socket, PulseAudio/Pipewire, udev, dbus and on top of that, depending on the GPU, you'll have to install the correct drivers, software packages and pass the right options to the docker run command (see the docs on GOW: run on desktop, NVIDIA config.

Some might say this looks like a completely different project and that's probably why you should point people to GOW instead 😉

@ABeltramo
Copy link
Collaborator

I was thinking about avoiding duplicating efforts, the best way forward might be to provide a skeleton Docker image which includes the latest Sunshine build similar to what you have right now (just fix the entrypoint).

Since there's no one way of running Sunshine, with this anyone can create their own Docker image based on what they want to achieve; for example:

FROM  lizardbyte/sunshine

# install Wayland and Steam

ENTRYPOINT start-wayland && start-steam && start-sunshine

You also don't have to deal with PID/GUID/TZ or any other runtime option, just keep a simple docker image that people can expand on.

Let me know what you think!

@ReenigneArcher
Copy link
Member Author

I was thinking about avoiding duplicating efforts, the best way forward might be to provide a skeleton Docker image which includes the latest Sunshine build similar to what you have right now (just fix the entrypoint).

Since there's no one way of running Sunshine, with this anyone can create their own Docker image based on what they want to achieve; for example:

FROM  lizardbyte/sunshine

# install Wayland and Steam

ENTRYPOINT start-wayland && start-steam && start-sunshine

You also don't have to deal with PID/GUID/TZ or any other runtime option, just keep a simple docker image that people can expand on.

Let me know what you think!

Revisiting this again. I agree with this idea and my updates to this branch "should" reflect that.

These items from your previous review should be fixed as well.

  • build and several other directories/files added to .dockerignore
  • TZ, PUID and PGID args removed
  • sunshine binary should now be at /usr/bin/sunshine (actually fixed by fix path issues #330 )
  • DOCKER_README.md updated (still probably lacking)

Not real sure about the CPU and ram usage. My only guess would be that Sunshine was continuously crashing and restarting?

@ABeltramo
Copy link
Collaborator

I have to spend some more time in trying this out with GOW but I have a quick suggestion, first:

TZ, PUID and PGID args removed

This is probably not the best way forward; processes in Docker container shouldn't run as root. I think it would be better to create a default user but also give users the ability to override that at build time (if needed).

Something like:

FROM sunshine-base as sunshine

# copy deb from builder
COPY --from=sunshine-build /root/sunshine-build/build/cpack_artifacts/Sunshine.deb /sunshine.deb

# install sunshine
RUN apt-get update -y \
     && apt-get install -y --no-install-recommends /sunshine.deb \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/*

ENV TZ="Europe/London"
ARG UNAME=retro
ENV UNAME=${UNAME}
ARG PUID=1000
ENV PUID=${PUID}
ARG PGID=1000
ENV PGID=${PGID}

RUN groupadd -f -g "${PGID}" "${UNAME}"
RUN useradd -mk "$(mktemp -d)" -u "${PUID}" -g "${PGID}" "${UNAME}"

ENV HOME=/home/$UNAME

USER ${UNAME}

# network setup
EXPOSE 47984-47990/tcp
EXPOSE 48010
EXPOSE 47998-48000/udp

# setup config directory
RUN mkdir ${HOME}/config

# entrypoint
ENTRYPOINT ["/usr/bin/sunshine", "${HOME}/config/sunshine.conf"]

- add user setup
- simplify `ENTRYPOINT` by creating symbolic link to user's config directory

Co-Authored-By: ABeltramo <[email protected]>
@ReenigneArcher ReenigneArcher force-pushed the update/docker branch 2 times, most recently from bf7625e to 497e609 Compare October 27, 2022 03:25
@ReenigneArcher ReenigneArcher merged commit dcdd716 into nightly Oct 28, 2022
@ReenigneArcher ReenigneArcher deleted the update/docker branch October 28, 2022 01:51
@ReenigneArcher ReenigneArcher mentioned this pull request Oct 28, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants