Building with Docker¶
The samples rely on Docker not only for the Genvid Services, but also for building and running the website. Although you can install a version of Docker locally (see Install Docker on Windows for more information), having access to a cloud provider can provide us with a simpler alternative [*]: We can create a Docker build server directly on Amazon EC2 using Docker Machine. The process is very straightforward and should take less than 5 minutes.
[*] | A future version of the SDK will likely support building the website directly on the servers, but it is not available right now. |
The first step is to find an availability zone that you have access:
aws ec2 describe-availability-zones --query AvailabilityZones[0].ZoneName --output text
This will return a name, e.g., us-east-1b
. The last letter
correspond to the availability zone and everything else is the region.
In the example above, the region name would be us-east-1
and the
availability zone is b
. You can now create a Docker machine on
this availability zones. Using the value above, you get:
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. Once
you are done with the machine, you can always shut it down:
bin\docker-machine rm [docker-name]
Building your project¶
You can now choose the sample you want to try. Let’s start with
tutorial
.
Our tutorial is a small game, with very little content. Therefore, we
can simply build an archive and make it available for upload under the
images
subdirectory. The command also builds the website which, as
stated previously, requires Docker to succeed. To advertise your
Docker installation or server, you must run the following command:
# 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]
should be replaced with the name previously
chosen, or default
if you are running Docker locally. Once this
is done, you can build the game using the following script command:
cd samples/tutorial
py tutorial.py build-cloud
This will automatically build two archives in the images
subdirectory. Note that the script puts a checksum in the image name.
The old images are removed (if necessary). A production version of
the script should probably be more conservative and keep the old
version, but right now, the old version is always removed.