Skip to content

Instantly share code, notes, and snippets.

@ru1t3rl
Last active July 9, 2024 06:16
Show Gist options
  • Select an option

  • Save ru1t3rl/941655049d664dece0b546e2ceb10169 to your computer and use it in GitHub Desktop.

Select an option

Save ru1t3rl/941655049d664dece0b546e2ceb10169 to your computer and use it in GitHub Desktop.
Docker image for windows il2cpp build on ubuntu

Build Instructions

1. Setup

Make sure docker is installed on your development machine. Download the all Dockerfile's above and place them in the same folder.

2. Open folder

Navigate to the folder of the docker files and open a terminal in the folder.

3. Build the wine image

docker build -t unityci/wine:latest -f Wine.dockerfile .

4. Build the hub image

docker build -t unityci/wine-hub:latest -f UnityHub.dockerfile .

5. Build the editor image

Replace ${...} with the corresponding variables

docker build --build-arg UNITY_VERSION=${UNITY_VERSION} --build-arg CHANGE_SET=${CHANGE_SET} -t unityci/ubuntu-${UNITY_VERSION}-windows-il2cpp -f UnityEditor.dockerfile
# Use the Unity CI base image
FROM unityci/wine-hub:latest
# Build arguments
ARG UNITY_VERSION=2022.3.34f1
ARG CHANGE_SET=4886f5360533
# Set environment variables
ENV UNITY_EDITOR_PATH="C:/Program\ Files/Unity\ ${UNITY_VERSION}/Editor/Unity.exe"
RUN mkdir /root/.wine/drive_c/UnityEditor
RUN unity-hub -- --headless install-path --set "C:/UnityEditor"
RUN unity-hub -- --headless install -v ${UNITY_VERSION} -c ${CHANGE_SET}
RUN unity-hub -- --headless install-modules -v ${UNITY_VERSION} -c ${CHANGE_SET} -m windows-il2cpp --cm
# In game-ci windows editor docker image thes was necessary due to unexpected behaviour
RUN xvfb-wine foreach ("$service" in 'nlasvc', 'netprofm') {"Set-Service $service -StartupType Automatic"}
# Create a script for unityeditor command
RUN echo '#!/bin/bash\nxvfb-wine ${UNITY_EDITOR_PATH}" "$@"' > /usr/local/bin/unityeditor && chmod +x /usr/local/bin/unityeditor
# Set the entrypoint to unityeditor
ENTRYPOINT ["unityeditor"]
FROM unityci/wine:latest
ENV UNITY_HUB_PATH="C:/Program Files/Unity Hub/Unity Hub.exe"
RUN wget https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe -O HubSetup.exe
RUN xvfb-wine HubSetup.exe /S
RUN rm -f HubSetup.exe
RUN echo '#!/bin/bash\nxvfb-wine "${UNITY_HUB_PATH}" "$@"' > /usr/local/bin/unity-hub && chmod +x /usr/local/bin/unity-hub
ENTRYPOINT ["bash", "unity-hub"]
# Use the Unity CI base image
FROM unityci/base:ubuntu-latest
# Set environment variables
ENV WINEARCH=win64
ENV WINEPREFIX=/root/.wine
ENV DISPLAY=:4
# Add i386 architecture and set up Wine repository
RUN dpkg --add-architecture i386 \
&& mkdir -pm755 /etc/apt/keyrings \
&& wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key \
&& wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources \
&& apt-get update
# Install Wine and other necessary packages
RUN apt install winehq-devel winetricks --install-recommends -y
RUN apt install -y \
xvfb \
x11-utils \
libx11-dev \
libxext-dev \
libxi-dev \
libxrender-dev \
libxtst-dev \
libxcursor-dev \
libxinerama-dev \
libxfixes-dev \
libxdamage-dev \
libxcomposite-dev \
libxrandr-dev
# Clean up apt cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Create an alias for Wine to use xvfb-run
RUN echo '#!/bin/bash\nxvfb-run -n 4 -e /dev/stdout --server-args="-ac -nolisten tcp -screen 0 1024x768x24 -noreset" wine "$@"' > /usr/local/bin/xvfb-wine && chmod +x /usr/local/bin/xvfb-wine
# Setup wine-mono
RUN wget https://gist.githubusercontent.com/jflemer/a1125763ea3fdb1fde2ca296675c7039/raw/5d731056c79fa4822964eb40036791596bc673fd/install-wine-addon.sh \
&& chmod +x install-wine-addon.sh \
&& ./install-wine-addon.sh mono \
&& rm -f install-wine-addon.sh
# Ensure winetricks runs with win10
RUN winetricks -q win10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment