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

An example docker file for building bevy on Ubuntu #11768

Closed
cs50victor opened this issue Feb 7, 2024 · 6 comments
Closed

An example docker file for building bevy on Ubuntu #11768

cs50victor opened this issue Feb 7, 2024 · 6 comments
Labels
C-Docs An addition or correction to our documentation O-Linux Specific to the Linux desktop operating system X-Controversial There is active debate or serious implications around merging this PR

Comments

@cs50victor
Copy link

How can Bevy's documentation be improved?

Please can we have a sample docker file for building bevy in a docker container

Tried running this but it errors out with this error message compile_error!("The platform you're compiling for is not supported by winit");

cs50victor/newmedia@25c07ba

@cs50victor cs50victor added C-Docs An addition or correction to our documentation S-Needs-Triage This issue needs to be labelled labels Feb 7, 2024
@alice-i-cecile alice-i-cecile added O-Linux Specific to the Linux desktop operating system X-Controversial There is active debate or serious implications around merging this PR and removed S-Needs-Triage This issue needs to be labelled labels Feb 9, 2024
@alice-i-cecile
Copy link
Member

Shipping and maintaining this is a large burden: I'd be opposed to doing so unless it was automatically tested with a enthusiastic volunteer owning the upkeep.

@mockersf
Copy link
Member

mockersf commented Feb 9, 2024

Tried running this but it errors out with this error message compile_error!("The platform you're compiling for is not supported by winit");

This error probably means that winit is detecting a linux but not finding one of the environment supported, x11 or wayland.

Why are you trying to run an application that tries to open a window inside a docker? If you want to have that working, you'll need to install x11, a virtual display server (xvfb is known to work with Bevy), and vulkan drivers in your container

@cs50victor
Copy link
Author

hey @alice-i-cecile @mockersf, I'm working on a headless renderer plugin for bevy (https://github.com/cs50victor/bevy_headless). My use case is to run a game on a container and have users connect to it. ( like Google's Stadia project ). When I run it locally it doesn't open a window so I'm wondering if I can get rid of winit or suppress the errors. Is this feasible at the moment, can I hack around bevy's source code even though the winit seems somewhat tightly coupled to the renderer.

  • I also volunteer to maintain / upkeep a docker example that allows these features

@mockersf
Copy link
Member

What you would want ideally is #22
I looked a bit and it seems very hard to do for now, Bevy calls Instance::create_surface_unsafe to create the surface it renders too, and that needs a window handle. Our current window handle comes from winit, we would need a library that provides a window handle without creating a window... not sure that's possible

The other way is the one I highlighted in my previous comment, with a virtual display server and x11 in a docker. I have a dockerfile around that is not minimal that I use to reproduce some CI issues:

FROM ubuntu:22.04

RUN apt-get update
# Build tools
RUN apt-get install -y -qq build-essential curl git software-properties-common pkg-config xorg openbox xauth
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Bevy dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -yq libasound2-dev libudev-dev libxkbcommon-x11-0
RUN apt-get update -y -qq
RUN add-apt-repository ppa:kisak/turtle -y
RUN apt-get update
RUN apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
ENV CARGO_TARGET_DIR="../rust-target"
ENV PATH="/root/.cargo/bin:${PATH}"

# Build Bevy from git, to fill cache
RUN git clone https://github.com/bevyengine/bevy bevy-git
WORKDIR /bevy-git
RUN cargo build -p example-showcase
RUN cargo build --release


SHELL ["/bin/bash", "-c"]
WORKDIR /bevy

CMD xvfb-run -s "-screen 0 1280x1024x24" cargo run -p example-showcase -- run --screenshot --in-ci --ignore-stress-tests

running it with your local bevy repo mounted as /bevy should work, run all examples and capture their screenshots: docker run --init --rm -v `pwd`:/bevy runner

@cs50victor
Copy link
Author

Thanks for letting me know trying to uncouple winit is not really possible at the moment ( before I learnt the heard way ). I'll test your Dockerfile and give you feedback.

@cs50victor
Copy link
Author

It worked. Thanks @mockersf. Really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Docs An addition or correction to our documentation O-Linux Specific to the Linux desktop operating system X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

No branches or pull requests

3 participants