Chapter Five: Auto Build Repositories

After this tutorial, you will know how to:

  • Link a git repository to Alauda.io
  • Build and launch a Docker image on Alauda.io
  • Enable auto-build to automatically rebuild an image on git push

Linking Git to Alauda.io

Adventurer, you know you can use git for version control, and a hosted git service like Github or Bitbucket to store your code, right?

-> Yes, of course.

Did you know you can link that repo to Alauda.io?

-> Why would I want to do that?

It lets you do all sorts of things, like lose weight fast with one simple trick and get money back on your taxes.

-> Yeah, yea--what? Really?

No.

-> ...

:)

Anyways. It does let you do a couple important things, like having Alauda.io run build jobs for you to build Docker images, which you can then launch (as a Service) running on Alauda Instances. It even lets you automate this process with an auto-build repository. Let me show you how.

First we'll need to link your git repository. After logging in you'll be greeted with the Services dashboard. Click on Profile.

From here, scroll down until you see Code Repository Accounts.

Simply click through to link (or unlink!) an account of your choice.

-> Ooh what's Git@OSC?

That's Git @ Open Source China. Did you know Alauda.io also has a Chinese service, Alauda.cn? You should check it out :)

--> Cool!

Building and Launching a Docker Image with Alauda.io

Head back over to the Repositories page and click Create New Repository. We'll choose Auto Build Repository from the drop down (the process for creating a regular Repository is the same).

-> Hey Alana, hold on a sec. When you say "Repository" here, didn't we already link a git repo up above?

Yes, we did! Here "Repository" refers to a repository of a Docker Image, rather than a git repo. This Docker Image repository is automatically hosted and managed for you by Alauda.io. All you have to do is point it to the Dockerfile. Confusingly, this Dockerfile and attendant miscellnaeous code will often be hosted in...a git repo!

-> Ah, clear as mud. Thanks.

I know it sounds confusing, and it is, but it ends up being quite convenient for you, as we'll see in the third part of this tutorial about auto-build: simply push some code to git and your Docker image automatically gets rebuilt, ready to be launched as Service!

Go ahead and select a relevant Git repo.

  • A friendly note from your narrator documentation writer: If you've having trouble deciding, feel free to fork the following repo and play along at home.

We'll be working with this Hello Flask repo for the rest of the tutorial.

Once you're ready hit Create. You'll be greeted with a shiny new Repository!

-> Alright, awesome! Let's Launch this sucker! Launch! Launch! Launch!

Not so fast, my young padawan. In this case it's the green arrow we'll want to follow. You can't Launch what you haven't Built yet!

Go ahead and click Trigger Build and grab a cup of coffee. Builds are relatively fast, but still on the order of minutes rather than seconds.

With your image successfully built, you can click that Launch button from before and configure a Service to run this Docker Image.

-> But Alana, what if I want to update my image? Do I have to build it again and do all these steps myself?

I'm so glad you asked...

Putting the "Auto" in Auto Build

You can see the auto build happen by pushing some code to the git repo. The simplest thing to do is to edit the "hello world" message in hello-flask/hello-flask/app.py Once you git push you'll see Alauda.io start to auto build.

Below we've edited it in a super sneaky fashion. See if you can spot the edit!

-> Spotted it...

Wasn't that fun! As you can see, Auto Build is a pretty powerful concept. Enjoy!