Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Latest commit

 

History

History
88 lines (52 loc) · 4.66 KB

File metadata and controls

88 lines (52 loc) · 4.66 KB
description
How to use Heroku as your hosting solution for your Battlesnake, using one of the Starter Projects.

Heroku

Prerequisites

These instructions assume you have already installed the Git Command Line and Heroku Command Line tools.

Step 1: Select a Starter Project

Choose from the complete list of Starter Projects. The Official Starter Projects have been tested and are maintained by the Battlesnake team.

For whichever Starter Project you choose, you will need to:

  • Click the green 'Use This template' button (or if unavailable, make a fork of the repo).

'Use this template' will create a new repository on your GitHub account with the contents of the repo

  • ****Clone your repository into your local environment. Run the following in the console on your computer with your own GitHub username, and the language for whichever starter project you selected:

git clone git@github.com:[YOUR-GITHUB-USERNAME]/starter-snake-[LANGUAGE].git

{% hint style="info" %} If you are using a Community Starter Project, the name of the repository may be different, and might not start with starter-snake-LANGUAGE. Check the project repository to confirm the correct name for your command! {% endhint %}

Step 2: Create and run a Heroku App

To run your Battlesnake, Create a new Heroku App **** by running the following in the console on your local computer:

heroku create [YOUR-APP-NAME]

The first URL in the output will be the URL where your Battlesnake will be run. You will need this URL in Step 3 to Register your Battlesnake.

{% hint style="info" %} Check the Language Support Page if you are getting errors about versions when attempting to create or push your code to Heroku. {% endhint %}

Once created, you can deploy your Battlesnake code to Heroku by running the command:

git push heroku main

{% hint style="info" %} If you are using a Community Starter Project, the mainline git branch might be different. Check the project repository to see if it is called main, master, or something else! {% endhint %}

Now you can open your new Heroku app in your browser to see your Battlesnake running:

heroku open

If everything was successful, you should see response text that looks like this:

{"apiversion": "1", "author": "", "color": "#ff0000", "head": "default", "tail": "default"}

Optionally, you can view your server logs using the Heroku log command. The --tail option will show a live feed of your logs in real-time.

heroku logs --tail

Step 3: Register your Battlesnake

Using the URL from Step 2, follow the instructions to Register your Battlesnake on the Battlesnake website. With Heroku, that URL will look something like https://my-app-name.herokuapp.com/ where my-app-name is the name you used in Step 2.

Once your Battlesnake is registered, you should also follow the instructions to Create your First Game to test and verify that your Battlesnake is communicating successfully. Be sure to watch the logs of your server by running the heroku logs --tail command.

Step 4: Making Changes and Updating your Battlesnake with Heroku

As you make changes to your Battlesnake code, you will need to make sure those changes get onto Heroku.

After making a code change, commit that change using git and then push it to your Heroku instance:

git add .
git commit -m "Message describing the change"
git push heroku main

Once Heroku has updated, you can create a new game with your Battlesnake to view your latest changes in action.

Continue to make code changes and push those changes to your server using this pattern.