category: Getting Started

Git is a commonly used code versionning system, and the technology used to deploy applications to Stormancer clusters.

An Advanced knowledge of git is not necessary to deploy applications to Stormancer. You can easily find git cmd prompt clients for your OS on the official git site. If you don't want to use the command prompt, another options are Github for Windows or SourceTree (both are free)

The article will use the official git cmd.

Tracking your app with git

Before being able to deploy your app, you must first create a local repository and commit the files to deploy in it. Start a command prompt in the base directory of your app (the one containing the _app.json file), create the repository then add the files to it.

>cd myapp
>git init
>git add .
>git commit -m "initial commit"

The repository itself now resides in the .git folder included in the project's directory.

However, nothing was sent to Stormancer for now. To do that, you must add a remote repository and push your repository to it.

Creating a remote on Stormancer

Git remotes are references to remote repositories. You can have any number of these, but for now we’ll focus on just the remote to Stormancer.

A repository is automatically created on Stormancer when you create an application. So first connect to the management portal and create an application.

The application page displays the url of the application's repository.

repository url

Copy the url and create the remote:

>git remote add stormancer <url>

Please note that Stormancer git repositories currently only support HTTP transport.

Deploying code

Your Stormancer app starts with a blank repository. It has no code and no branch in it. That means that the first time you deploy, you will need to specify a branch to push from your local repository to the Stormancer remote:

>git push stormancer master

This will push your code to the stormancer remote, created earlier. Use this whenever you want to deploy the latest code committed in Git to Stormancer.

Branches pushed to Stormancer other than master will be ignored by this command. If you’re working out of another branch locally, you can either merge to master before pushing, or specify that you want to push your local branch to a remote master. To push a branch other than master, use this syntax:

>git push stormancer yourbranch:master

To learn more about the app deployment process, seethis article.

Authentication

Authentication is handled using the basic HTTP auth protocol. When executing a command on the remote, Git will ask you for your identifiers:

Username is the email address you used to create your user.

A list of available passwords is accessible on the application page. (see the screenshot above). Passwords are linked with your Stormancer user account, and can be created or revoked on the account page.

Deploying from a subfolder in a Git repository

Sometime, you may want to put your server application in a subfolder of a main git repository. For instance, you may want to control your server source along the game client source.

However, we have already seen that the _app.json file must be at the root of the server repository.

Thanks to the git subtree module, it's possible (and surprisingly easy) to deploy to Stormancer from such a subfolder.

From the root of your repository, run the following git command (assuming Stormancer is the name of your deployment remote and you want to deploy the master branch:

>git subtree push stormancer --prefix <server-path> master

Order: 4