Spaces:
Running
Running
| FROM unityci/editor:ubuntu-2022.3.10f1-linux-il2cpp-3 | |
| USER root | |
| # Gunakan ARG agar bisa ganti role saat build (master, android, windows-mono, webgl) | |
| ARG SPACE_ROLE=master | |
| ENV SPACE_ROLE=${SPACE_ROLE} | |
| ENV UNITY_VERSION=2022.3.10f1 | |
| ENV UNITY_PATH=/opt/unity/Editor/Unity | |
| # 1. Install Dependencies & Unity Hub (Wajib untuk Worker) | |
| RUN apt-get update && apt-get install -y \ | |
| python3 python3-pip libnss3 ca-certificates wget gnupg \ | |
| && pip3 install --no-cache-dir fastapi uvicorn boto3 requests httpx \ | |
| # --- PROSES INSTALASI UNITY HUB --- | |
| && if [ "$SPACE_ROLE" != "master" ]; then \ | |
| wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor -o /usr/share/keyrings/Unity_Technologies_ApS.gpg \ | |
| && echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list \ | |
| && apt-get update && apt-get install -y unity-hub \ | |
| # Register Editor yang sudah ada di image agar Hub tahu lokasinya | |
| && unity-hub editors --register --version ${UNITY_VERSION} --path ${UNITY_PATH} \ | |
| # Install modul sesuai role (misal: android atau windows-mono) | |
| && unity-hub install-modules --version ${UNITY_VERSION} --module ${SPACE_ROLE} --childModules; \ | |
| fi \ | |
| && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| # 2. Environment & Permissions | |
| ENV HOME=/tmp | |
| WORKDIR /app | |
| RUN mkdir -p /tmp/.local/share/unity3d/Unity /tmp/.config/unity3d /tmp/.cache/unity3d && \ | |
| chmod -R 777 /tmp | |
| # Copy Project | |
| COPY --chown=1000:1000 . /app | |
| RUN chmod -R 777 /app | |
| USER 1000 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |