WIP: Mega Image

This commit is contained in:
Lachee 2025-09-18 14:09:49 +10:00
parent 6d910d6f2f
commit 7750334d0e
No known key found for this signature in database
GPG Key ID: F1694B0D3BCBCD55
3 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,109 @@
#!/bin/sh
# Ensure UNITY_VERSION is set, pull from arguments if not
if [ -z "${UNITY_VERSION}" ]; then
if [ -n "$1" ]; then
UNITY_VERSION=$1
else
echo "Error: UNITY_VERSION is not set."
exit 1
fi
fi
# Fetch the changelog and extract the changeset ID for the specified Unity version
CHANGELOG_URL="https://public-cdn.cloud.unity3d.com/hub/prod/releases-${UNITY_VERSION}.json"
CHANGESET_ID=$(curl -s "$CHANGELOG_URL" | grep -o '"changeset":[^,]*' | head -n 1 | cut -d':' -f2 | tr -d ' "')
if [ -z "$CHANGESET_ID" ]; then
echo "Warning: Could not retrieve changeset ID for Unity version ${UNITY_VERSION}."
else
echo "Unity ${UNITY_VERSION} changeset ID: ${CHANGESET_ID}"
fi
# Ensure we have some modules
if [ -z "${UNITY_MODULES}" ]; then
if [ -n "$3" ]; then
UNITY_MODULES=$3
else
echo "Error: UNITY_MODULES is not set."
exit 1
fi
fi
# Ensure IMAGE is set, pull from arguments if not
if [ -z "${IMAGE}" ]; then
if [ -n "$3" ]; then
IMAGE=$3
else
echo "Error: IMAGE is not set."
exit 1
fi
fi
# Ensure GAME_CI_VERSION is set, default to 3 if not
if [ -z "${GAMECI_VERSION}" ]; then
GAMECI_VERSION=3
fi
# Ensure IMAGE_OS is set, default to ubuntu if not
if [ -z "${GAMECI_OS}" ]; then
# windows-il2cpp requires windows OS
if [ "${UNITY_PLATFORM}" = "windows-il2cpp" ]; then
GAMECI_OS="windows"
else
GAMECI_OS="ubuntu"
fi
# TODO: MacOS probably requires a mac image.
# Might be worth just putting this in the strategy at this point
fi
# Ensure PLATFORM is set, default to the current system if not
if [ -z "${PLATFORM}" ]; then
PLATFORM=$(uname -m)
case "${PLATFORM}" in
x86_64) PLATFORM="linux/amd64" ;;
arm64) PLATFORM="linux/arm64" ;;
*)
echo "Error: Unsupported platform ${PLATFORM}."
exit 1
;;
esac
fi
# Ensure some additional build settings are set
if [ -z "${DOCKER_BUILD_ARGS}" ]; then
DOCKER_BUILD_ARGS=""
fi
BASE_TAG=${GAMECI_OS}-${UNITY_VERSION}-base-${GAMECI_VERSION}
BASE_IMAGE=unityci/editor:${BASE_TAG}
DEST_TAG=${GAMECI_OS}-${UNITY_VERSION}-runner
DEST_IMAGE=${IMAGE}:${DEST_TAG}
echo "Building Docker image ${DEST_IMAGE}"
echo "- Platfrom: ${PLATFORM}"
echo "- Base: ${BASE_IMAGE}"
echo "- Tag: ${DEST_TAG}"
echo "- Image: ${DEST_IMAGE}"
docker build \
--platform ${PLATFORM} \
--build-arg "VERSION=${UNITY_VERSION}" \
--build-arg "BASE_IMAGE=${BASE_IMAGE}" \
--build-arg "MODULE=${UNITY_MODULES}" \
-t ${DEST_IMAGE} \
${DOCKER_BUILD_ARGS} \
.
if [ $? -ne 0 ]; then
echo "Error: Docker build failed."
exit 1
fi
# Export IMAGE and TAG for GitHub Actions
if [ -n "$GITHUB_OUTPUT" ]; then
echo "IMAGE=${IMAGE}" >> $GITHUB_OUTPUT
echo "TAG=$DEST_TAG" >> $GITHUB_OUTPUT
echo "FULL_IMAGE=${DEST_IMAGE}" >> $GITHUB_OUTPUT
fi

View File

@ -1,5 +1,45 @@
ARG BASE_IMAGE=unityci/editor ARG BASE_IMAGE=unityci/editor
ARG HUB_IMAGE="unityci/hub"
###########################
# Builder #
###########################
FROM $HUB_IMAGE AS builder
# Install editor
ARG VERSION
ARG CHANGE_SET
RUN unity-hub install --version "$VERSION" --changeset "$CHANGE_SET" | \
tee /var/log/install-editor.log && grep 'Failed to install\|Error while installing an editor\|Completed with errors' /var/log/install-editor.log | \
exit $(wc -l)
# Install modules for that editor
ARG MODULE="non-existent-module"
RUN for mod in $MODULE; do \
if [ "$mod" = "base" ] ; then \
echo "running default modules for this baseOs"; \
else \
unity-hub install-modules --version "$VERSION" --module "$mod" --childModules | tee /var/log/install-module-${mod}.log && \
grep 'Missing module\|Completed with errors' /var/log/install-module-${mod}.log | exit $(wc -l); \
fi \
done \
# Set execute permissions for modules
&& chmod -R 755 /opt/unity/editors/$VERSION/Editor/Data/PlaybackEngines
RUN echo "$VERSION-$MODULE" | grep -q -vP '^(2021.2.(?![0-4](?![0-9]))|2021.[3-9]|202[2-9]|[6-9][0-9]{3}|[1-9][0-9]{4,}).*linux' \
&& exit 0 \
|| unity-hub install-modules --version "$VERSION" --module "linux-server" --childModules | \
tee /var/log/install-module-linux-server.log && grep 'Missing module' /var/log/install-module-linux-server.log | exit $(wc -l);
RUN echo "$VERSION-$MODULE" | grep -q -vP '^(2021.2.(?![0-4](?![0-9]))|2021.[3-9]|202[2-9]|[6-9][0-9]{3}|[1-9][0-9]{4,}).*windows' \
&& exit 0 \
|| unity-hub install-modules --version "$VERSION" --module "windows-server" --childModules | \
tee /var/log/install-module-windows-server.log && grep 'Missing module' /var/log/install-module-windows-server.log | exit $(wc -l);
###########################
# Editor #
###########################
FROM $BASE_IMAGE FROM $BASE_IMAGE
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y \ apt-get install -y \

4
test.sh Normal file
View File

@ -0,0 +1,4 @@
UNITY_VERSION=6000.0.35f1 \
UNITY_MODULES="webgl linux-server windows-mono mac-mono linux-il2cpp" \
IMAGE=docker.lakes.house/unityci/editor \
./.gitea/workflows/scripts/build-runner-image.sh