Tutorials

Hello Dotmesh on Docker

Getting Started with Dotmesh on Docker

You're gonna need.

Clone the app

The moby counter app is a very basic drawing app: it allows you to click to put logos on the screen. The location of the logos is persisted to a Redis database.

First, clone the app repo from gihub.


git clone https://github.com/dotmesh-io/moby-counter
cd moby-counter

The docker-compose file includes not only the app but also a request for a Docker volume from a dotmesh datadot.

Start the app.


docker-compose up -d

You can see that the datadot referenced in the docker-compose file has been created.


dm list

Make moby_counter the current datadot.


dm switch moby_counter

This means that later dm commands will operate on that datadot, as indicated by the * in the list.


dm list
  VOLUME       BRANCH  SERVER   CONTAINERS  SIZE       COMMITS  DIRTY
* moby_counter master  8f15abe  /moby       19.00 kiB  1        9.50 kiB

Capture the empty state

Now, let’s capture the empty state, run:


dm commit -m "Empty state"

Now, load up the app in your browser at http://localhost:8100/ – you’ll see an invitation to click on the screen. Before you do, let’s make a new branch:


dm checkout -b branch_a

Draw an A on the screen

Now, draw an “A” on the screen! Then capture it:


dm commit -m "A on the screen"

Note that if you go back to the master branch, the app updates automatically and you go back to your empty state:


dm checkout master

Let’s go back to the A state, as next we’ll push it to the dothub.


dm checkout branch_a

Push “A state” to the dothub

At this point, try pushing your branch to Dothub.

Start by registering for an account by clicking the link above.

Then back here, we’ll set an environment variable with your Dothub username in it:

export HUB_USERNAME=<username>

Then add the hub as a remote:


dm remote add hub ${HUB_USERNAME}@dothub.com

You will be prompted for your API key, which you can get from the Settings/API Key page.

You can then push branches to the hub.


dm push hub moby_counter branch_a

Then, go to Dothub and you should be able to see the volume, its branches and commits.

Optional: Adding a collaborator

Prove that data can move between machines by inviting a friend or co-worker to join the Dothub too!

When they’ve signed up, add them as a collaborator, by going to the Settings page for your datadot, and type their user’s username to add them as a collaborator.

Finally, send them a link to the following section so that they can clone your datadot and then you can finish the tutorial together!

Instructions for your co-worker

So you been invited to pull down someone else’s datadot? Great, let’s do it!

First, sign up for an account on the Dothub.

Then tell the person who sent you here to add you as a collaborator to their dot.

You’re gonna need:

Next, let’s set up some environment variables.

export DOT_OWNER=<their-username>
export COLLABORATOR=<your-username>

Authenticate to the hub:


dm remote add hub ${COLLABORATOR}@dothub.com

You will be prompted for your API key, which you can get from the Settings/API Key page.

Clone the repo locally


git clone https://github.com/datamesh-io/moby-counter
cd moby-counter

Clone and switch to the dot before you start the app:


dm clone hub ${DOT_OWNER}/moby_counter

Make moby_counter the current datadot.


dm switch moby_counter

This means that later dm commands will operate on that datadot, as indicated by the * in the list.


dm list

Start the app:


docker-compose up -d

Pull and checkout the branch your co-worker created earlier:


dm pull hub moby_counter branch_a
dm checkout branch_a

Now navigate to http://localhost:8100/ and you should see the same data that your coworker created running locally!

What’s next?

Try a more advanced version of the app with multiple microservices and polyglot persistence, and start building up a set of interesting states for your team in: