game-ci / docker

Series of CI-specialised docker images for Unity.
https://hub.docker.com/u/unityci
MIT License
392 stars 121 forks source link

Dedicated Server support for Linux is not installed after updating from 2022.3.16f1 to 6000.0.0f1 #244

Closed paulbreuler closed 2 months ago

paulbreuler commented 2 months ago

Bug description

Linux server build fails in GitHub Actions after update of Unity Editor version from unityci/editor:ubuntu-2022.3.16f1-linux-il2cpp-3.0.1 to unityci/editor:ubuntu-6000.0.0f1-linux-il2cpp-3.0.1

Error:

#152 142.8 Error building Player: Dedicated Server support for Linux is not installed.

How to reproduce

Run build of Unity project in container.

# linux-specific Unity build
FROM --platform=$BUILDPLATFORM unityci/editor:ubuntu-6000.0.0f1-linux-il2cpp-3.0.1 AS build-unity-linux
WORKDIR "/src"
COPY --from=build-dependencies /src/src/SomeProject/ .
RUN --mount=type=secret,id=UNITY_USERNAME \
    --mount=type=secret,id=UNITY_PASSWORD \
    --mount=type=secret,id=UNITY_LICENSE \
    unity-editor -quit -batchmode -serial $(cat /run/secrets/UNITY_LICENSE) -username $(cat /run/secrets/UNITY_USERNAME) -password $(cat /run/secrets/UNITY_PASSWORD) && \
    unity-editor -quit -batchmode -nographics -buildTarget Linux64 -standaloneBuildSubtarget Server -executeMethod Builder.Build -projectPath . && \
    unity-editor -quit -batchmode -returnlicense -username $(cat /run/secrets/UNITY_USERNAME) -password $(cat /run/secrets/UNITY_PASSWORD)

Expected behavior

Build should succeed.

Previously used

FROM --platform=$BUILDPLATFORM unityci/editor:ubuntu-2022.3.16f1-linux-il2cpp-3.0.1 AS build-unity-linux

Additional details

I'm on MacOS so grabbing a Windows Machine to try to repro locally for more details. Currently running in GH Actions, where build had been working until version change.

paulbreuler commented 2 months ago

Perhaps tied to regex check for version before installing server modules:

RUN echo "$version-$module" | grep -q -vP '^(2021.2.(?![0-4](?![0-9]))|2021.[3-9]|202[2-9]|20[3-9]).*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]|20[3-9]).*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);

https://github.com/game-ci/docker/blob/main/images/ubuntu/editor/Dockerfile

Something like this would work to cover version 6+ and 10+ assuming this version style is maintained.

Regex addition:

^([6-9][0-9]{3}|[1-9][0-9]{4,}).*

Makes the final pattern a bit gross but likely works, haven't tested yet.

POTENTIAL SOLUTION:

RUN echo "$version-$module" | grep -q -vP '^(2021.2.(?![0-4](?![0-9]))|2021.[3-9]|202[2-9]|20[3-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]|20[3-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);
AndrewKahr commented 2 months ago

I actually discovered this a few hours ago while trying to fix the android modules. Your regex is much better than what I had though so I went ahead and incorporated it into my branch. Will try to fast track this to a release. Thanks for chasing this down!

AndrewKahr commented 2 months ago

The fix is live for Unity 6 images. Check to see if dedicated server is working for you now and if it is we can close this issue

paulbreuler commented 2 months ago
#146 144.2 Asset Pipeline Refresh (id=905952f5a7a50c95394e27c5dcd177f1): Total: 0.022 seconds - Initiated by StopAssetImportingV2(NoUpdateAssetOptions)
#146 144.2 Error building Player: Dedicated Server support for Linux is not installed.

Maybe the image isn't built out yet?

AndrewKahr commented 2 months ago

That's odd I see this in the build log: [Linux Dedicated Server Build Support] installed successfully. Maybe pull the image locally and manually check the expected files exist for it?

AndrewKahr commented 2 months ago

Also make sure you're using the updated image version. Not sure if you've pinned it to 3.0.1 or if that's just what was latest when you ran it. It should be 3.1.0 now

paulbreuler commented 2 months ago

That's probably it!

paulbreuler commented 2 months ago

That did the trick. I didn't see docs on pinning versions. I just noticed in unityci/editor each image has the version in the name.

Is there a string I should use to just pull the latest?

Updated to -3.1.0

# add file level variables
ARG UnityVersion=6000.0.0f1
ARG UnityCiDockerVersion=3.1.0

# build dependencies
...Truncated...

# linux-specific Unity build
FROM --platform=$BUILDPLATFORM unityci/editor:ubuntu-${UnityVersion}-linux-il2cpp-${UnityCiDockerVersion} AS build-unity-linux
WORKDIR "/src"
COPY --from=build-dependencies /src/src/someProject/ .
# Install the Linux Server Build module
RUN echo "Building User Interface for Linux..."
RUN --mount=type=secret,id=UNITY_USERNAME \
    --mount=type=secret,id=UNITY_PASSWORD \
    --mount=type=secret,id=UNITY_LICENSE \
    unity-editor -quit -batchmode -serial $(cat /run/secrets/UNITY_LICENSE) -username $(cat /run/secrets/UNITY_USERNAME) -password $(cat /run/secrets/UNITY_PASSWORD) && \
    unity-editor -quit -batchmode -nographics -buildTarget Linux64 -standaloneBuildSubtarget Server -executeMethod Builder.Build -projectPath . && \
    unity-editor -quit -batchmode -returnlicense -username $(cat /run/secrets/UNITY_USERNAME) -password $(cat /run/secrets/UNITY_PASSWORD)
RUN echo "Building User Interface for Linux... completed"

# windows-specific Unity build
FROM --platform=$BUILDPLATFORM unityci/editor:ubuntu-${UnityVersion}-windows-mono-3.0.1 AS build-unity-windows
WORKDIR "/src"
RUN echo "Building User Interface for Windows..."
COPY --from=build-dependencies /src/src/someProject/ .
RUN --mount=type=secret,id=UNITY_USERNAME \
    --mount=type=secret,id=UNITY_PASSWORD \
    --mount=type=secret,id=UNITY_LICENSE \
    unity-editor -quit -batchmode -serial $(cat /run/secrets/UNITY_LICENSE) -username $(cat /run/secrets/UNITY_USERNAME) -password $(cat /run/secrets/UNITY_PASSWORD) && \
    unity-editor -quit -batchmode -nographics -buildTarget win64 -standaloneBuildSubtarget Server -executeMethod Builder.Build -projectPath . && \
    unity-editor -quit -batchmode -returnlicense -username $(cat /run/secrets/UNITY_USERNAME) -password $(cat /run/secrets/UNITY_PASSWORD)# linux-specific base
RUN echo "Building User Interface for Windows... completed"

# platform-dynamic build-unity
FROM build-unity-${TARGETOS} AS build-unity

# linux-specific base
FROM ubuntu:latest AS base-linux
USER $APP_UID
ENTRYPOINT ["./someProject.x86_64"]

# windows-specific base
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 AS base-windows
ENTRYPOINT ["some.exe"]

# platform-dynamic final
FROM base-${TARGETOS} AS final
EXPOSE 7777/udp
WORKDIR /app
COPY --from=build-unity "src/Build/" .
COPY src/someProject/Assets/appsettings.json someProject_Data/
AndrewKahr commented 2 months ago

If you use just 3 as the version it will be the latest version with a major version of 3