This video outlines the process for getting a Unity WebGL build working inside of an Apache web server container with a docker.
Requirements
- Unity Editor
- Azure DevOps Account w/ Agent installed & configured.
- Docker Desktop
- Administrative access to device
Notes
Docker Destop’s daemon will have an access denied issue if the Azure Pipeline Agent service account in services isn’t in the docker-users group on the machine. The fix is to add the service account to the docker users or change the service account to the user account that has access. You’ll have to restart the service and docker desktop for the changes to take effect.
Steps
- Download & Install Docker Desktop.
- Download & Install WSL2 from docker desktop prompt & follow additional instructions
- Go to services and change the Agent service to account in “docker-users” group -> (Account you installed docker in).
- Restart the service and docker desktop.
- Create docker file with the code below.
- Put docker file into the root of your unity project.
- upload to repo with github desktop or git client of your choice.
- Open pipeline and Add docker build task.
- Under Unity Build task make sure the Output path is $(Build.BinariesDirectory).
- Make sure Output filename is WebGL (the folder with the WASM and index.html).
- Open docker task and change command to build.
- Set Docker file to $(Build.SourcesDirectory)/Dockerfile.
- Set Build Context to $(Build.BinariesDirectory)/WebGL/.
- Add to Argument field -t test-webgl-build to set the image name(tag).
- Execute pipeline and check docker desktop images for the name(tag).
- Execute image as a container with advanced property (port) to 8080.
- Open browser and navigate to localhost:8080 or 127.0.0.1:8080.
Dockerfile
FROM httpd:latest
COPY ./ /usr/local/apache2/htdocs/