game-ci / game-ci/docker

Editor Lite image

Open
#74 10 comments 12 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dockerfile
Stars
470
Forks
140
PR merge metrics
No merged PRs in 30d

Description

**Description**
Some time ago I've started to investigate can the image be smaller. I've managed to reduce image size three times (from 3 GB to 1 GB). The reasoning behind my research was that the private GitHub repo has a limited amount of action execution minutes. And seems like downloading the docker image is a significant part of the run tests action. By decreasing the size of the image, we reduced the time of the unity-test-runner from 5.0 mins to 2.3 mins.

![image](https://user-images.githubusercontent.com/1926766/107281264-7d86dc80-6a6a-11eb-9593-82dec139683c.png)
![image](https://user-images.githubusercontent.com/1926766/107281286-82e42700-6a6a-11eb-8cc5-35860bf02921.png)

But since I'm not interested in fighting around pull requests to this repo and do not have time to test all the limitations & edge cases I want just to share with you the dockerfile to let the community decide is it feasible to take some of my findings and cut them out from the official image.

Dockerfile:
```
ARG baseImage=unityci/base:latest
ARG editorImage=unityci/editor:2020.2.1f1-base-0

FROM $editorImage as builder

# Templates
RUN echo 'Cleaning image' \
# Remove templates
&& rm -rf /opt/unity/Editor/Data/Resources/PackageManager/ProjectTemplates/ \
&& rm -rf /opt/unity/Editor/Data/Resources/PackageManager/PackageTemplates/ \
# Remove everything except manifest from packages
&& find /opt/unity/Editor/Data/Resources/PackageManager/Editor/ \
! -name 'manifest.json' \
-type f -exec rm -f {} + \
# Remove unnecessary Mono resources
&& rm -rf /opt/unity/Editor/Data/MonoBleedingEdge/lib/mono/monodoc/ \
&& rm -rf /opt/unity/Editor/Data/MonoBleedingEdge/bin-linux32 \
# SDK is not required for .NET Core
&& rm -rf /opt/unity/Editor/Data/NetCore/Sdk-* \
# We are not planning to debug in CI
&& rm -rf /opt/unity/Editor/Unity_s.debug \
# Remove playback engines
&& rm -rf /opt/unity/Editor/Data/PlaybackEngines/

###########################
# Editor #
###########################

FROM $baseImage

# Always put "Editor" and "modules.json" directly in $UNITY_PATH
ARG UNITY_PATH=/opt/unity
COPY --from=builder "$UNITY_PATH/" "$UNITY_PATH/"

# Alias to "unity-editor" with default params
RUN echo '#!/bin/bash\nxvfb-run -ae /dev/stdout "$UNITY_PATH/Editor/Unity" -batchmode "$@"' > /usr/bin/unity-editor \
&& chmod +x /usr/bin/unity-editor
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.