Skip to main content
  1. Blogs/

Developing GUI App (Bevy) in VSCode DevContainer (Wayland)

·253 words·2 mins·
code rust tips bevy

I wanted to experiment with developing a game using the Bevy Engine, but didn’t want to install a bunch of dependencies on my computer. I wanted to keep things contained in a VS Code Dev Container. The tricky part was getting Wayland support working for the demos.

This required crafting a slightly custom Dockerfile and devcontainer.json.

First, I enabled Wayland socket binding in vscode by going into Settings and enabling “Mount Wayland Socket”:

vscode devcontainer config

Here’s the Dockerfile I’m using, although it has several unnecessary packages for just adding Wayland support. Several of these are for x11.

.devcontainer/Dockerfile

FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye 

# Install the necessary system libraries
RUN apt-get update && apt-get install -y \   
    pkg-config \    
    libasound2-dev \
    libudev-dev \   
    mesa-utils \ 
    vulkan-tools \
    libwayland-dev \
    libxkbcommon-dev \   
    libvulkan1 \    
    libvulkan-dev \ 
    libegl1-mesa-dev \   
    libgles2-mesa-dev \  
    libx11-dev \    
    libxcursor-dev \
    libxrandr-dev \
    libxi-dev \
    libxrandr-dev \
    libxcb1-dev \
    libxcb-icccm4-dev \
    libxcb-image0-dev \
    libxcb-keysyms1-dev \
    libxcb-randr0-dev \
    libxcb-shape0-dev \
    libxcb-xfixes0-dev \
    libxcb-xkb-dev \
    libegl1-mesa \
    libgl1-mesa-glx \
    libgl1-mesa-dri \
    libglu1-mesa-dev \
    libglu1-mesa \
    libgles2-mesa \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json


{
	"name": "Rust",
	"build": {
		"dockerfile":"Dockerfile",
		"context": "."
	},
	"mounts": [
		"source=/dev/dri,target=/dev/dri,type=bind",
		"source=/dev/snd,target=/dev/snd,type=bind",
		"source=/etc/asound.conf,target=/etc/asound.conf,type=bind",
    ],
	"runArgs": [
		"--privileged",
        
        // Had to add some groups for dri and snd access
		"--group-add", "17",
		"--group-add", "26",
		"--group-add", "303"
	]

}

That should be enough to get Wayland access inside the container. x11 apps should work too.

Modify Cargo.toml to include Wayland support in Bevy:

[dependencies]
bevy = { version = "0.11", features = ["wayland"] }

Related

Clever preprocessor macro in HLSL
·457 words·3 mins
hlsl code tips gpu
A single method that can work with either a List or an Array (IEnumerable and ICollection)
·296 words·2 mins
unity code tips c#
Round a number to some multiple of another number
·201 words·1 min
code tips
Testing C# code in the browser
·42 words·1 min
code tips c#
Element-wise Vector Multiplication in Unity (Vector3.Scale)
·79 words·1 min
unity code tips
The top 5 things Ive learned as an Indie Unity Developer
·1402 words·7 mins
unity programming code tips