Customize GameCI Unity Docker images
Sometimes, you will want to add tools to the existing unity docker images for specific needs. For example, in some projects, you might need Blender installed for unity to allow building a project with blender assets. Sometimes, you'll need some specific command lines or runtime that are used by unity in a postprocess step. This documentation will guide you into building your own images on top of the existing ones to add your desired tools.
Example: Add Ruby to existing images
In the following example, we will be adding Ruby
on top of the existing docker images (all unity
components) for the 2021.1.16f1
unity version and GameCI's 0.15.0
version and publish them.
Build script
build.sh
#!/usr/bin/env bash
set -ex
UNITY_VERSION=2021.1.16f1
GAME_CI_VERSION=0.15.0 # https://github.com/game-ci/docker/releases
MY_USERNAME=gableroux
# don't hesitate to remove unused components from this list
declare -a components=("android" "ios" "linux-il2cpp" "mac-mono" "webgl" "windows-mono")
for component in "${components[@]}"
do
GAME_CI_UNITY_EDITOR_IMAGE=unityci/editor:ubuntu-${UNITY_VERSION}-${component}-${GAME_CI_VERSION}
IMAGE_TO_PUBLISH=${MY_USERNAME}/editor:ubuntu-${UNITY_VERSION}-${component}-${GAME_CI_VERSION}
docker build --build-arg GAME_CI_UNITY_EDITOR_IMAGE=${GAME_CI_UNITY_EDITOR_IMAGE} . -t ${IMAGE_TO_PUBLISH}
# uncomment the following to publish the built images to docker hub
# docker push ${IMAGE_TO_PUBLISH}
done
Dockerfile
Dockerfile
# initially inspired from https://github.com/drecom/docker-ubuntu-ruby/blob/master/Dockerfile
ARG RUBY_PATH=/usr/local/
ARG RUBY_VERSION=2.6.0
ARG GAME_CI_UNITY_EDITOR_IMAGE
# build ruby
FROM ubuntu:18.04 AS rubybuild
RUN apt-get update \
&& apt-get upgrade -y --force-yes \
&& apt-get install -y --force-yes \
libssl-dev \
libreadline-dev \
zlib1g-dev \
wget \
curl \
git \
build-essential \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
ARG RUBY_PATH
ARG RUBY_VERSION
RUN git clone git://github.com/rbenv/ruby-build.git $RUBY_PATH/plugins/ruby-build \
&& $RUBY_PATH/plugins/ruby-build/install.sh
RUN ruby-build $RUBY_VERSION $RUBY_PATH
# inject ruby and additional dependencies in game-ci's unity editor image
FROM $GAME_CI_UNITY_EDITOR_IMAGE
ARG RUBY_PATH
ENV PATH $RUBY_PATH/bin:$PATH
RUN apt-get update && \
apt-get install -y \
git \
curl \
gcc \
make \
libssl-dev \
zlib1g-dev \
libsqlite3-dev
COPY $RUBY_PATH $RUBY_PATH
Usage example
Locally, invoke the build.sh
script (example on a unix system):
chmod +x build.sh
./build.sh
As a result, you will now have your own docker image with desired tools available during build time.
To confirm ruby
is correctly installed, we can invoke the command within the image we just built:
docker run --rm -it gableroux/editor:ubuntu-2021.1.16f1-android-0.15.0 ruby --version
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
If you are using github-actions unity-builder you can then customize the docker image used during build using the customimage parameter
For more information on how to publish to docker hub, you may refer to docker's documentation
Example : Include Blender
To include blender in the image used to build your unity project, you can define a custom Dockerfile based on unityci/editor and install blender on top of it.
Dockerfile
ARG GAMECI_IMAGE=unityci/editor:2021.3.1f1-windows-mono-1.0.1
FROM $GAMECI_IMAGE
ARG BLENDER_SHORT_VERSION=3.4
ARG BLENDER_FULL_VERSION=3.4.1
RUN echo "BLENDER_SHORT_VERSION: $BLENDER_SHORT_VERSION"
RUN echo "BLENDER_FULL_VERSION: $BLENDER_FULL_VERSION"
RUN apt-get update && \
apt-get install -y wget && \
wget https://download.blender.org/release/Blender$BLENDER_SHORT_VERSION/blender-$BLENDER_FULL_VERSION-linux-x64.tar.xz && \
tar -xf blender-$BLENDER_FULL_VERSION-linux-x64.tar.xz && \
rm blender-$BLENDER_FULL_VERSION-linux-x64.tar.xz
ENV PATH="$PATH:/blender-$BLENDER_FULL_VERSION-linux-x64"
Usage
You can build this image and upload it to your own Dockedhub registry to reference it in your Unity pipeline afterward.