Skip to content

Commit

Permalink
Merge pull request #492 from nick-l-o3de/merge_stabilization_to_main
Browse files Browse the repository at this point in the history
Merge stabilization/2409 to main for release 24.09.0
  • Loading branch information
nick-l-o3de authored Oct 9, 2024
2 parents ed2f4e8 + b765b55 commit 3f0b8d2
Show file tree
Hide file tree
Showing 115 changed files with 5,142 additions and 843 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea/
.vs/
.vscode/
.command_settings
_savebackup/
.mayaSwatches/
*.swatches
Expand All @@ -10,5 +11,6 @@ _savebackup/
Sounds/wwise_project/*.wsettings
CMakeUserPresets.json
*.code-workspace
project.json.bak*
AssetBundling/AssetLists/
AssetBundling/Bundles/
AssetBundling/Bundles/
125 changes: 125 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#

ARG INPUT_ARCHITECTURE=amd64

ARG INPUT_IMAGE=ubuntu

ARG INPUT_TAG=jammy

FROM ${INPUT_ARCHITECTURE}/${INPUT_IMAGE}:${INPUT_TAG}

# Argument for determining the package type ('server', 'headless-server', 'game', or 'unified-launcher')
ARG PACKAGE_TYPE=game # Default to 'game'

# o3de repo arguments
ARG O3DE_REPO=https://github.com/o3de/o3de
ARG O3DE_BRANCH=development
ARG O3DE_COMMIT=HEAD

# o3de-extras repo arguments
ARG O3DE_EXTRAS_REPO=https://github.com/o3de/o3de-extras
ARG O3DE_EXTRAS_BRANCH=development
ARG O3DE_EXTRAS_COMMIT=HEAD

# o3de-multiplayersample repo arguments
ARG O3DE_MPS_REPO=https://github.com/o3de/o3de-multiplayersample
ARG O3DE_MPS_BRANCH=development
ARG O3DE_MPS_COMMIT=HEAD

# o3de-multiplayersample-assets repo arguments
ARG O3DE_MPS_ASSETS_REPO=https://github.com/o3de/o3de-multiplayersample-assets
ARG O3DE_MPS_ASSETS_BRANCH=development
ARG O3DE_MPS_ASSETS_COMMIT=HEAD


# Argument to run fullscreen (for game, unified, and server package types)
ARG RUN_FULLSCREEN=0

# Set the workspace to work from
ENV WORKSPACE=/data/workspace
WORKDIR $WORKSPACE

# o3de Environment
ENV O3DE_REPO=$O3DE_REPO
ENV O3DE_BRANCH=$O3DE_BRANCH
ENV O3DE_COMMIT=$O3DE_COMMIT
ENV O3DE_ROOT=$WORKSPACE/o3de

# o3de-extras Environment
ENV O3DE_EXTRAS_REPO=$O3DE_EXTRAS_REPO
ENV O3DE_EXTRAS_BRANCH=$O3DE_EXTRAS_BRANCH
ENV O3DE_EXTRAS_COMMIT=$O3DE_EXTRAS_COMMIT
ENV O3DE_EXTRAS_ROOT=$WORKSPACE/o3de-extras

# o3de-multiplayersample Environment
ENV O3DE_MPS_ASSETS_REPO=$O3DE_MPS_ASSETS_REPO
ENV O3DE_MPS_ASSETS_BRANCH=$O3DE_MPS_ASSETS_BRANCH
ENV O3DE_MPS_ASSETS_COMMIT=$O3DE_MPS_ASSETS_COMMIT
ENV O3DE_MPS_ASSETS_ROOT=$WORKSPACE/o3de-multiplayersample-assets

# o3de-multiplayersample-assets Environment
ENV O3DE_MPS_REPO=$O3DE_MPS_REPO
ENV O3DE_MPS_BRANCH=$O3DE_MPS_BRANCH
ENV O3DE_MPS_COMMIT=$O3DE_MPS_COMMIT
ENV O3DE_MPS_ROOT=$WORKSPACE/o3de-multiplayersample

# Validate and set the package type
RUN if [ $PACKAGE_TYPE = "game" ];then echo "Building Game Launcher Image"; \
elif [ $PACKAGE_TYPE = "unified" ];then echo "Building Unified Launcher Image"; \
elif [ $PACKAGE_TYPE = "server" ];then echo "Building Server Launcher Image"; \
elif [ $PACKAGE_TYPE = "headless" ];then echo "Building Headless Server Launcher Image"; \
else echo "Invalid PACKAGE_TYPE argument '$PACKAGE_TYPE'. Must be one of ('server', 'headless', 'game', or 'unified')" && exit 1; \
fi
ENV PACKAGE_TYPE=$PACKAGE_TYPE
ENV RUN_FULLSCREEN=$RUN_FULLSCREEN

# Add additional package repositories needed for packages
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
ca-certificates \
git \
git-lfs \
libstdc++-12-dev \
clang\
ninja-build \
cmake \
libglu1-mesa-dev \
libxcb-xinerama0 \
libxcb-xinput0 \
libxcb-xinput-dev \
libxcb-xfixes0-dev \
libxcb-xkb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev \
libfontconfig1-dev \
libcurl4-openssl-dev \
libsdl2-dev \
zlib1g-dev \
mesa-common-dev \
libssl-dev \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-render-util0 \
libxcb-randr0 \
libnvidia-gl-470 \
libunwind-dev \
libzstd-dev \
binutils-dev \
libvulkan1

COPY build.sh $WORKSPACE/build.sh
COPY launch.sh $WORKSPACE/launch.sh

RUN $WORKSPACE/build.sh \
&& rm $WORKSPACE/build.sh

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all

ENTRYPOINT ["/bin/bash", "-c", "/data/workspace/launch.sh"]
119 changes: 119 additions & 0 deletions Docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Docker support for Multiplayer Sample

The O3DE Multiplayer Sample supports construction of Docker images on the Linux environment.

## Prerequisites

* [Hardware requirements of o3de](https://www.o3de.org/docs/welcome-guide/requirements/)
* Any Linux distribution that supports Docker and the NVIDIA container toolkit (see below)
* **Note** For the headless server flavor, the NVIDIA container toolkit is not required.
* At least 60 GB of free disk space
* Docker installed and configured
* **Note** It is recommended to have Docker installed correctly and in a secure manner so that the Docker commands in this guide do not require elevated priviledges (sudo) in order to run them. See [Docker Engine post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) for more details.
* [NVidia container toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)

# Building the Docker image
The Docker scripts accepts arguments to control how to build the Docker image for the Multiplayer Sample. The main argument, `PACKAGE_TYPE` controls the type of launcher that will be built from the Docker build process. There are four different types of launchers supported:

1. **game** : The game client that will connect to a game server.
2. **server** : The game server that will accept remote game clients and will also provide a display of running game sessions.
3. **unified** : The combined game client that also can run as the game server.
4. **headless** : The game server that will accept remote game clients but will not display and GUI or window. This is launcher is designed to run on headless servers.

In addition to `PACKAGE_TYPE`, there are additional arguments that can control how the Docker image is built:

| Argument | Description | Default
|-------------------------|----------------------------------------------------------------------------|-------------
| INPUT_ARCHITECTURE | The CPU architecture (amd64/aarch64). Will require QEMU if cross compiling | amd64
| INPUT_IMAGE | The base linux distro docker image to base the build on | ubuntu
| INPUT_TAG | The base linux distro docker image tag to base the build on | jammy
| O3DE_REPO | The git repo for O3DE | https://github.com/o3de/o3de
| O3DE_BRANCH | The branch for O3DE | development
| O3DE_COMMIT | The commit on the branch for O3DE (or HEAD) | HEAD
| O3DE_EXTRAS_REPO | The git repo for O3DE Extras | https://github.com/o3de/o3de-extras
| O3DE_EXTRAS_BRANCH | The branch for O3DE Extras | development
| O3DE_EXTRAS_COMMIT | The commit on the branch for O3DE Extras (or HEAD) | HEAD
| O3DE_MPS_REPO | The git repo for main Multiplayer Sample project | https://github.com/o3de/o3de-multiplayersample
| O3DE_MPS_BRANCH | The branch for main Multiplayer Sample project | development
| O3DE_MPS_COMMIT | The commit on the branch for Multiplayer Sample project (or HEAD) | HEAD
| O3DE_MPS_ASSETS_REPO | The git repo for Multiplayer Sample Assets | https://github.com/o3de/o3de-multiplayersample-assets
| O3DE_MPS_ASSETS_BRANCH | The branch for Multiplayer Sample Assets | development
| O3DE_MPS_ASSETS_COMMIT | The commit on the branch for Multiplayer Sample Assets (or HEAD) | HEAD
| RUN_FULLSCREEN | Option to launch the game, unified, or server in fullscreen mode (0=no, 1=yes) | 0


## Examples

### Locally (From the o3de-multiplayersample/Docker folder)
The following examples will be the different supported types of launchers using the local Docker context folder in the `o3de-multiplayersample` local repo.

#### Game Launcher
```
docker build --build-arg PACKAGE_TYPE=game -f Dockerfile -t amd64/o3de-mps-game:jammy .
```
#### Unified Game Launcher
```
docker build --build-arg PACKAGE_TYPE=unified -f Dockerfile -t amd64/o3de-mps-unified:jammy .
```
#### Server Launcher
```
docker build --build-arg PACKAGE_TYPE=server -f Dockerfile -t amd64/o3de-mps-server:jammy .
```
#### Headless Server Launcher
```
docker build --build-arg PACKAGE_TYPE=headless -f Dockerfile -t amd64/o3de-mps-headless:jammy .
```

### From github
The following examples will be the different supported types of launchers using the Docker context found in the github repo for `o3de-multiplayersample` and the `development` branch.

#### Game Launcher
```
docker build --build-arg PACKAGE_TYPE=game -t amd64/o3de-mps-game:jammy https://github.com/o3de/o3de-multiplayersample.git#development:Docker
```
#### Unified Game Launcher
```
docker build --build-arg PACKAGE_TYPE=unified -t amd64/o3de-mps-unified:jammy https://github.com/o3de/o3de-multiplayersample.git#development:Docker
```
#### Server Launcher
```
docker build --build-arg PACKAGE_TYPE=server -t amd64/o3de-mps-server:jammy https://github.com/o3de/o3de-multiplayersample.git#development:Docker
```
#### Headless Server Launcher
```
docker build --build-arg PACKAGE_TYPE=headless -t amd64/o3de-mps-headless:jammy https://github.com/o3de/o3de-multiplayersample.git#development:Docker
```


# Running the Docker image locally
Running the non-headless Docker images requires Vulkan and GPU acceleration provided by the NVIDIA drivers and container toolkit. The following directions will describe how to launch the Docker containers, utilizing the host Linux machine's X11 display and NVIDIA drivers, and connecting to the default 'bridge' network. (For advanced network isolation, refer to Docker's command-line reference for [network](https://docs.docker.com/reference/cli/docker/container/run/#network))



#### Game Launcher
```
xhost +local:root
docker run --rm --gpus all -e DISPLAY=:1 --network="bridge" -v /tmp/.X11-unix:/tmp/.X11-unix -it amd64/o3de-mps-game:jammy
```
#### Unified Game Launcher
```
xhost +local:root
docker run --rm --gpus all -e DISPLAY=:1 --network="bridge" -v /tmp/.X11-unix:/tmp/.X11-unix -it amd64/o3de-mps-unified:jammy
```
#### Server Launcher
```
xhost +local:root
docker run --rm --gpus all -e DISPLAY=:1 --network="bridge" -v /tmp/.X11-unix:/tmp/.X11-unix -it amd64/o3de-mps-server:jammy
```
#### Headless Server Launcher
```
docker run --network="bridge" -it amd64/o3de-mps-headless:jammy
```
>**Note** Headless server does not require access to the host display or NVIDIA drivers


# Deploying the Docker image
The Docker image can be published to any docker container registry and deployed on any Linux operating system that supports Docker.


Loading

0 comments on commit 3f0b8d2

Please sign in to comment.