Article: Building Docker images for Unreal Engine 4

How to build both Windows and Linux Docker images for Epic Games’ Unreal Engine 4.

Tags: C++, DevOps, Docker, Unreal Engine

Contents

Overview

In the concluding remarks of the article Cross-platform library integration in Unreal Engine 4, I stated that my proposed integration workflow was only the first step in building the foundation of a Continuous Integration (CI) pipeline for UE4 that supports the seamless use of third-party libraries. Another key ingredient in a modern CI pipeline is the ability to use containers as part of the build process. Container-based builds provide a wide array of benefits over bare metal or virtual machine-based builds, including reduced resource requirements and a clean filesystem for each build. Additionally, the use of containers sidesteps the limitation that UnrealBuildTool is only designed to allow a single instance to run at any given time on a system.

Although there have been a small handful of efforts to build Docker-based containers for UE4, all of these have focussed solely on Linux containers. I am aware of no existing projects that aim to provide Dockerfiles for Windows container builds of UE4. Additionally, most of the existing Linux Dockerfiles appear to be geared toward the ability to run the UE4 Editor in a container on a standalone host, rather than to create an environment suitable for use in a CI pipeline.

After considerable experimentation, I have developed a set of Dockerfiles and an accompanying Python build script that provide the necessary functionality to build both Windows and Linux Docker images for Unreal Engine 4 which are suitable for use in a CI pipeline. The code is available from the adamrehn/ue4-docker GitHub repository. It is important to remember that you cannot upload the built images to a public Docker Registry such as Docker Hub, since the Unreal Engine EULA prohibits Engine Licensees from publicly distributing the Engine Tools in any form. You can share the built images with other Engine Licensees via a private Docker Registry so long as you ensure that you do so in a manner that complies with the “private sharing” terms in the EULA.

The Dockerfiles and Python code in the ue4-docker repository are well-commented and should be largely self-documenting. However, if you are interested in the issues that I encountered in developing these files and the solutions that I employed to solve them, the section that follows provides an in-depth discussion.

Issues and their solutions

Issues common to both Windows and Linux containers

Issues specific to Windows containers

Issues specific to Linux containers

Next steps

With Docker images built for both Windows and Linux, the logical next step is to utilise them as part of a Continuous Integration (CI) pipeline. I will post an article in the near future with details on using the Docker images described above within the popular Jenkins CI system.

With regards to the distribution of built images, Epic Games themselves are the only entity with the legal right to alter the current situation. I have no doubt that many Engine Licensees would be delighted if Epic Games were to provide automated builds of UE4 Docker images via an Epic-hosted Docker Registry. Such a registry could be integrated with the Epic Games account system to provide authentication and would significantly simplify the developer effort required for Engine Licensees to implement self-hosted CI pipelines. In the meantime, the code in the ue4-docker repository provides developers with the ability to build and host UE4 Docker images themselves.