https://github.com/jamesalbert/deploy-unity
Deploy your Unity WebGL game to Amazon's Elastic Container Service
https://github.com/jamesalbert/deploy-unity
aws bash ecr ecs unity3d virtual-environments
Last synced: 3 months ago
JSON representation
Deploy your Unity WebGL game to Amazon's Elastic Container Service
- Host: GitHub
- URL: https://github.com/jamesalbert/deploy-unity
- Owner: jamesalbert
- License: apache-2.0
- Created: 2018-05-05T04:40:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-07T01:38:32.000Z (about 8 years ago)
- Last Synced: 2025-07-21T03:42:45.938Z (11 months ago)
- Topics: aws, bash, ecr, ecs, unity3d, virtual-environments
- Language: Shell
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deploy-unity

Deploy your Unity WebGL game to Amazon's Elastic Container Service using this handy-dandy virtual environment.
## How to Deploy Unity Builds
### Dependencies
- aws-cli
- ecs-cli
- jq
### Things you need:
- a domain ([guide](https://aws.amazon.com/getting-started/tutorials/get-a-domain/))
- a TLS certificate ([guide](https://aws.amazon.com/blogs/aws/new-aws-certificate-manager-deploy-ssltls-based-apps-on-aws/))
- an ECS cluster ([guide](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create_cluster.html)) and service ([guide](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service.html))
- name your service with the name you will set in `config.json`
- recommended: set your service behind an ALB ([guide](https://aws.amazon.com/blogs/compute/microservice-delivery-with-amazon-ecs-and-application-load-balancers/))
Create a CNAME under your domain that points to the ALB ([guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-elb-load-balancer.html)). Use the TLS certificate to encrypt the traffic between the client and the ALB ([guide](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html)). Then configure a target group to forward traffic to your service's tasks ([guide](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html)). This tool doesn't touch on any of these things, but you should have this setup before hosting a game.
Last thing to note is to ensure that the ECS task role you use have ecr:* and logs:* permissions. It doesn't have to be *that* open, but ¯\\\_(ツ)\_/¯.
### Configuration
Before you begin, be sure to have aws-cli and ecs-cli configured. If you don't already, follow this [guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) for aws-cli, and this [guide](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI_Configuration.html) for ecs-cli.
Once that's done, the first thing you need to do is fill out `config.json`:
- build_dir: build directory (where you built to from Unity)
- name: the name for your ECR repository, task definition, and service
- tag: tag your deploy (usually "latest")
- cluster: name of your cluster
- network_mode: bridge, host, awsvpc, or none
- task_role_arn: role arn the containers will assume
- execution_role_arn: role arn that container agents and docker daemon will assume
- network_mode: bridge, host, awsvpc, or none (not implemented, uses default)
- cpu: CPU units
- memory: MiB units
### Deploying
Reminder: you must have a cluster and service ready before deployment.
If you're ready to go, here are the steps:
- In Unity:
- click File>Build Settings...
- click WebGL
- configure your build
- click Build and choose this repo as the destination
- Here:
- run `. deploy_env.sh`
- run `deploy`
- when done, run `deactivate`
`deploy` will:
- login to ECR
- build the docker image (./Dockerfile)
- push the image to ECR
- create a new task definition revision
- update the service with the new task definiton
While in the deploy environment, you can:
- `ecr-login`: login to ECR
- `build`: build the local docker image
- `push`: push image (takes name from `config.json`.name) to ECR
- `revise`: create new task definition revision
- `update`: update the service with the new task definition
- `deactivate`: deactivate deploy environment
That's the basic flow of things. You can always version control your builds and use this in something like Jenkins.