Companion script for ue4-docker image builds
This powershell script will help clean, build and push your Unreal Engine docker images
Thu, 24 Aug 2023
I made this Powershell script to easily handle building my docker images for Unreal Engine since I now make an image for every engine release
param(
[Parameter(Mandatory=$true, HelpMessage="Engine version to build")]
[string]$version,
[Parameter(HelpMessage="The repo you want to push your image to (OPTIONAL)")]
[string]$repo,
[Parameter(HelpMessage="If specified, will clean all of the build images for the version specified in the variable version")]
[switch]$clean,
[Parameter(HelpMessage="If specified, will tag your image with repo:version and push it")]
[switch]$push,
[Parameter(Mandatory=$true, HelpMessage="Github user that has access to the Unreal Engine repo")]
[string]$user,
[Parameter(Mandatory=$true, HelpMessage="Github PAT for the user specified in user")]
[string]$token
)
if ($clean.IsPresent) {
Write-Host "Cleaning old build images for tag $($version)";
ue4-docker clean -tag $version;
} else {
Write-Host "Skipped cleaning of old build images";
}
Write-Host "Building Unreal Engine version: $($version).";
ue4-docker build $version -username $user -p $token --exclude debug --exclude templates --monitor --opt buildgraph_args="-set:GameConfigurations=Shipping;DebugGame;Development -set:HostPlatformOnly=true -set:WithClient=false -set:WithServer=false" --visual-studio=2022;
if ($push.IsPresent) {
$docker_tag = "$($repo):$($version)";
Write-Host "Creating tag for $($docker_tag)";
docker tag adamrehn/ue4-full:$($version) "$($docker_tag)";
docker push "$($docker_tag)";
} else {
Write-Host "Skipped cleaning of old build images";
}
Lets go over the basic usage
- user - github username
- token - github PAT
- version - version of the engine to build
- repo - optional, add this if you want to tag the image
- clean - optional, clean the existing docker build data
- push - optional, pushes the image tagged as repo:version combo