|
| 1 | +### Running with Docker |
| 2 | + |
| 3 | +Docker simplifies the setup process by providing a consistent development environment. It allows you to build and run the project without manually installing dependencies. Currently provided [Dockerfile.ubuntu.2404](../../packaging/docker/devenv/Dockerfile.ubuntu.2404) supports Ubuntu 24.04 as the base operating system. |
| 4 | + |
| 5 | +#### Prerequisites |
| 6 | + |
| 7 | +- **Docker**: Ensure Docker is installed on your machine. Follow the [official documentation](https://docs.docker.com/) for installation instructions. |
| 8 | +- **Display Server**: This guide supports both **X11** and **Wayland** display servers for GUI applications. |
| 9 | +- **Tested Configuration**: These instructions were tested on Ubuntu 24.04 running on WSL2 on Windows 11. |
| 10 | + |
| 11 | +#### Steps to Build and Run |
| 12 | + |
| 13 | +1. **Enable GUI Support** |
| 14 | + |
| 15 | + Depending on your display server, follow the appropriate steps: |
| 16 | + |
| 17 | + - **For X11**: |
| 18 | + Allow the Docker container to access your X server: |
| 19 | + ```bash |
| 20 | + xhost +local:root |
| 21 | + ``` |
| 22 | + |
| 23 | + - **For Wayland**: |
| 24 | + Allow the Docker container to access your Wayland socket: |
| 25 | + ```bash |
| 26 | + sudo chmod a+rw /run/user/$(id -u)/wayland-0 |
| 27 | + ``` |
| 28 | + |
| 29 | +2. **Build the Docker Image** |
| 30 | + |
| 31 | + Build the Docker image using the provided Dockerfile: |
| 32 | + ```bash |
| 33 | + sudo docker build -t openage -f packaging/docker/devenv/Dockerfile.ubuntu.2404 . |
| 34 | + ``` |
| 35 | + |
| 36 | +3. **Run the Docker Container** |
| 37 | + |
| 38 | + Start the Docker container with the appropriate configuration for your display server: |
| 39 | + |
| 40 | + - **For X11**: |
| 41 | + ```bash |
| 42 | + docker run -it \ |
| 43 | + -e DISPLAY=$DISPLAY \ |
| 44 | + -v /tmp/.X11-unix:/tmp/.X11-unix \ |
| 45 | + -v $HOME/.Xauthority:/root/.Xauthority \ |
| 46 | + --network host openage |
| 47 | + ``` |
| 48 | + |
| 49 | + - **For Wayland**: |
| 50 | + ```bash |
| 51 | + docker run -it \ |
| 52 | + -e XDG_RUNTIME_DIR=/tmp \ |
| 53 | + -e QT_QPA_PLATFORM=wayland \ |
| 54 | + -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \ |
| 55 | + -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \ |
| 56 | + --user=$(id -u):$(id -g) \ |
| 57 | + --network host openage |
| 58 | + ``` |
| 59 | + |
| 60 | +4. **Follow the Regular Setup** |
| 61 | + |
| 62 | +Once inside the container, follow the regular setup described in the [Development](../building.md#development) chapter. You can skip dependency installation since the Docker image already includes all required dependencies. |
| 63 | + |
| 64 | +#### Notes |
| 65 | + |
| 66 | +- **X11 vs. Wayland**: Ensure you know which display server your system is using. Most modern Linux distributions default to Wayland, but X11 is still widely used. |
| 67 | +- **Permissions**: For Wayland, you may need to adjust permissions for the Wayland socket (`/run/user/$(id -u)/wayland-0`) to allow Docker access. |
| 68 | +- **GUI Applications**: These configurations enable GUI applications to run inside the Docker container. |
| 69 | + |
| 70 | +By following these steps, you can build and run the `openage` project in a Dockerized environment with support X11 or Wayland display servers. |
0 commit comments