Quick how-to on using dart with Compute Engine. If not aware, right now is a great time to dive into Compute Engine cause google is giving away $2,000 worth of credits to individuals interested in trying it out. I’ve been using it for about 2-3 months now and totally love it.
What peeked my interest is it was flexable enough to run the dartvm as a server with minimal configuration. The one configuration hurdle was dependency of GLIBC >= 2.15
in the dartvm binaries. The good news is with a simple startup script the compute engine instance can be provisioned to support the latest linux dart-sdk.
The main tool we will use to provision a compute engine instance is gcutil. We could of used dartvm and google_compute_v1beta15_api but will save that for a later post.
After signing up for Compute Engine the next step should be to download and configure gcutil
.
1 2 3 4 5 |
|
Next we want to create a startup.sh
script that will be deployed to the compute engine instance. The script is a simple way to run additional commands to provision the instance. For dart we need to add a new deb
source, update sources, install dependencies, fetch & unpack dart-sdk, and then execute our dart server. In the final line of the startup.sh
script the command will create a dart server from the user account tied to this compute instance. Simply we clone a public git repo, install pub dependencies and screen a detached session that runs the dart server. This is not a very fancy way to deploy dart but a simple and quick way to get something running with no troubles. A real life deployment might include some trendy fab/chef/puppet combo.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
After we have the startup.sh
script we then create another deployment script. The following script will be the gcutil commands needed to actually create and provision the compute instance. The last part of our script includes a firewall rule for the port that the stream sample is running on. Without proper firewall rules no access from the outside is possible.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
And thats all that is needed to get dart on compute engine in two easy steps. The code can be found here gist.