bevy icon indicating copy to clipboard operation
bevy copied to clipboard

An example docker file for building bevy on Ubuntu

Open cs50victor opened this issue 1 year ago • 2 comments

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");

https://github.com/cs50victor/new_media/pull/18/commits/25c07ba742365a2ece80d1db7e747dabef62095c

cs50victor avatar Feb 07 '24 20:02 cs50victor

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.

alice-i-cecile avatar Feb 09 '24 16:02 alice-i-cecile

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

mockersf avatar Feb 09 '24 20:02 mockersf

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

cs50victor avatar Feb 13 '24 18:02 cs50victor

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

mockersf avatar Feb 15 '24 16:02 mockersf

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 avatar Feb 15 '24 20:02 cs50victor

It worked. Thanks @mockersf. Really appreciate it.

cs50victor avatar Feb 16 '24 04:02 cs50victor