DEV Community

Discussion on: Running an Unity WebGL game within Docker

Collapse
 
townofdon profile image
Don Juan Javier

Very helpful article, thanks! I wanted to test a Unity WebGL build and this pointed me in the right direction.

I ended up using a volume for the webgl directory so that changes to the build would be reflected immediately without needing to rebuild the docker image.

Also had to disable compression as I couldn't get the nginx config to serve *.gz files correctly. Some people are saying that server-side compression doesn't play nice with pre-compressed build files - (see this link).

Lastly, had to supply the -f flag to keep the rm command from failing if default.conf didn't exist.

My docker-compose.yml:

version: '3.8'

services:
  webgl:
    build: .
    ports:
      - "8080:80"
    volumes:
      - ./webgl:/webgl
Enter fullscreen mode Exit fullscreen mode

My Dockerfile:

FROM nginx:stable

WORKDIR /webgl
COPY webgl/ .
VOLUME /webgl

WORKDIR /etc/nginx/conf.d
RUN rm -f default.conf
COPY webgl.conf webgl.conf
Enter fullscreen mode Exit fullscreen mode
Collapse
 
tomowatt profile image
Tom Watt

I’m glad to hear this helped someone!

The article and setup is probably a bit out of date now and could do with a bit of a refresh. I’ll try and look into it again as I’ve recently done so more work with Unity.

But thank you also for sharing your configuration and the issues you met!