Docker¶
Building with Docker¶
The samples rely on Docker for both the Genvid Services and for building and running the website. Although you can install a version of Docker locally, creating a Docker build server directly on Amazon EC2 is a simpler alternative. (Docker Machine)
See Install Docker on Windows for more information about installing locally.
The first step is to find an availability zone you can use:
aws ec2 describe-availability-zones --query AvailabilityZones[0].ZoneName --output text
This returns a name where the last letter corresponds to the availability zone
and everything else is the region. For example, for the name us-east-1b
:
- The region name is
us-east-1
- The availability zone is
b
To create a Docker machine on this availability zone:
bin\docker-machine create --driver amazonec2 --amazonec2-region us-east-1 --amazonec2-zone b [docker-name]
The [docker-name]
is a unique name to refer to the machine.
When you’re done with the machine, you can shut it down using:
bin\docker-machine rm [docker-name]
Building Your Project¶
The Tutorial sample has only a small amount of content. So we can build an
archive and make it available for upload under the images
subdirectory.
This command also builds the website which requires Docker to succeed, so you
need to advertise your Docker installation or server.
# On Windows command prompt
@FOR /f "tokens=*" %i IN ('"bin\docker-machine" env [docker-name]') DO @%i
# On bash for Windows
eval $(bin/docker-machine env [docker-name])
# With Powershell
bin/docker-machine env [docker-name] | Invoke-Expression
Where [docker-name]
is the name you chose or default
if you’re running
Docker locally. When the command finishes, you can build the game and the web.
cd samples/cube/directx
py directx.py prepare
py directx.py build-cloud
cd ../web
py web.py build-cloud
This builds two archives in the respective images
subdirectory. Note that the
script puts a checksum in the image name and removes any old images. A
production version of the script should probably be more conservative and keep
the old version.