mob-sakai / docker-unity

New series of CI-specialised docker images for Unity. Superseding the famous gableroux/unity3d images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⚠️ NOTE: This project has been integrated into mob-sakai/docker, so we are NOT continuing development in this repository. ⚠️













Docker - Unity3d

Source of CI specialised docker images for Unity.

Inspired by game-ci/docker.





✳️ Changes from game-ci/docker

  • ⚠️ Removed features
    • backend-versioning server (Use workflow_dispatch and unity-changeset instead)
    • Unity project for test (Move to another branch)
  • Release automatically with semantic-release
  • Run workflow manually or automatically
  • Fast skip earlier builds of images that already exist
  • Support environment variables file (.env) for build settings
    • DOCKER_REGISTRY
    • DOCKER_USERNAME
    • BASE_IMAGE
    • HUB_IMAGE
    • EDITOR_IMAGE
    • MINIMUM_UNITY_VERSION
    • IGNORED_UNITY_VERSIONS
      • The build specifies an unstable version and prevents flooding of the error notifications
    • IGNORED_IMAGE_TAGS
  • Support for alpha/beta versions of Unity (e.g. 2020.2.0b, 2021.1.0a)
    • ⚠️ NOTE: The versions removed from Unity beta will not be updated
  • Grouping workflows in a module (base, ios, android, ...)
    • Improve the visibility of actions page
    • Easy to retry



🔨 How to build images

1. ✏️ Setup build configuration file (.env)

Overwrite DOCKER_REGISTRY, DOCKER_USERNAME, BASE_IMAGE, HUB_IMAGE and EDITOR_IMAGE in .env.

# Docker Hub: docker.io
# GitHub Container Registory: ghcr.io
DOCKER_REGISTRY=ghcr.io
DOCKER_USERNAME=mob-sakai

# Full image ID
BASE_IMAGE=ghcr.io/mob-sakai/unity_base
HUB_IMAGE=ghcr.io/mob-sakai/unity_hub
EDITOR_IMAGE=ghcr.io/mob-sakai/unity3d

Overwite MINIMUM_UNITY_VERSION, IGNORED_UNITY_VERSIONS and IGNORED_IMAGE_TAGS if you want.

# Minimum Unity version
MINIMUM_UNITY_VERSION=2018.3

# Ignored Unity versions (Regular expressions)
IGNORED_UNITY_VERSIONS="
^2020.2.0a
"

# Ignored image tags (Regular expressions)
IGNORED_IMAGE_TAGS="
^2018.*linux-il2cpp
^2019.1.*linux-il2cpp
^2019.2.*linux-il2cpp
"



2. 🔑 Setup repository secrets

Name Description
DOCKER_TOKEN The access token or passward to longin docker registory.
GH_WORKFLOW_TOKEN Github parsonal access token to dispatch workflow.



3. ▶️ Run workflows (automatically)

All workflows will be run automatically.

Workflow Description Trigger Inputs
Release Release new tag. Pushed commits (include feat or fix) on main branch -
Build All Build all images.
(base/hub/editor)
A new tag pushed -
Build Editor Build editor images with a specific Unity module Dispatched from Build All
module: Unity module to build.
repoTag: The repository tag to build.
Request Activation License File Request Activation License File Dispatched from Build Editor (Base) repoTag: The repository tag to build.



4. ▶️ Run workflows (manually)

You can run them manually from the Actions page.

NOTE: You need permissions to run the workflow.




🔧 Use custom image on Github Actions

jobs:
  unity-test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        unity:
          [
            2019.3.15f1,
            2019.4.16f1,
            2020.1.16f1,
          ]

    steps:
      - uses: actions/checkout@v2

      - uses: mob-sakai/unity-test-runner@main
        with:
          customImage: ghcr.io/mob-sakai/unity3d:${{ matrix.unity }}
          customParameters: "-nographics"
          testMode: editmode
        env:
          UNITY_LICENSE_FILE: .ulfs/Unity_v${{ matrix.unity }}.ulf

      - uses: actions/upload-artifact@v2
        if: failure()
        with:
          path: "*.alf"

https://unity-ci.com/docs/github/getting-started

https://github.com/webbertakken/unity-actions

Use with CustomImage parameter.




🔍 FAQ

❗ Error on time limit or API limit

Because the combination of the editor build is so large, the builds may fail due to the time limit of github actions (<6 hours) or API limitations.

Re-run Build All workflow manually after all jobs are done.

❗ Missing library for editor

If a missing library is found, fix the dockerfiles/editor.Dockerfile in local.

If the problem is solved, fix the dockerfiles/base.Dockerfile in the main branch.




💡 Next plans

  • Test the build for each patch versions (2018.3.0, 2018.3.1, ...)
    • May be unnecessary for stable versions (2018.x, 2019.x)
    • Build a simple project for all platforms
    • Inspect the missing library
  • Notify the error summary to mail, Slack or Discord

About

New series of CI-specialised docker images for Unity. Superseding the famous gableroux/unity3d images.

License:MIT License


Languages

Language:Dockerfile 73.9%Language:Shell 26.1%