Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

DevOps

In this lab you will learn how to deploy your app to a cloud server and how to set up a complete devops build chain. For this tutorial you will need to have an account on the GitLab server as we will be learning how to use the GitLab CI continuous integration tools. (Note that GitHub has recently introduced a rival service called GitHub Actions however at the time of writing this was still in Beta).

Create an account using your University email address and log in. Create an empty private repository called devops and make a note of the git clone URL.

You should now clone the template-dynamic-website repository (the original template, not the one you have been using for your assignment) into a temporary location on your computer.

git clone https://github.coventry.ac.uk/web/template-dynamic-websites.git temp

Once cloned you need to mirror push to the empty gitlab repository.

cd temp/ && git push --mirror xxx

2 Deploying to the Cloud

In this task you will learn how to deploy apps to the Heroku cloud.

Create yourself an account on the Heroku website and verify the account is live by logging into the website. Whilst you can create new apps from this screen we will be doing this through the Codio terminal window.

2.1 Configuring the Server

We will be interacting with Heroku using a command-line utility. Open up the Terminal window in Codio and install it using the detailed instructions on their website.

Then you need to log into Heroku from the command-line to exchange SSH keys.

$ heroku login
  Enter your Heroku credentials.
    Email: marktyers@gmail.com     
    Password (typing will be hidden):
  Authentication successful.

Next we need to create our remote app on the cloud, replacing <appname> with the name you chose for your app (this should be your university username followed by -test, for example doej-test. If you don't specify a name parameter one will be automatically generated for you.

$ heroku create <appname>
  Creating <appname>... done, stack is cedar-14
  https://<appname>.herokuapp.com/ | https://git.heroku.com/<appname>.git
  Git remote heroku added

If you check your git remotes you should find that heroku has added a second one.

git remote -v
heroku  https://git.heroku.com/<appname>.git (fetch)
heroku  https://git.heroku.com/<appname>.git (push)
origin  git@gitlab.com:marktyers/Heroku.git (fetch)
origin  git@gitlab.com:marktyers/Heroku.git (push)

2.2 Deploying to Heroku

Assuming the git working directory is clean, deploying is as simple as pushing to the heroku remote instead of the origin remote. To push to the Heroku server:

$ git push heroku master

This will push the latest commits to the Heroku server. Once this is completed, the server will be stopped and then restarted using the information contained in the config file. You should be able to view the progress by checking the messages appearing in the terminal window.

The first time the app gets deployed we need to start an app instance running.

$ heroku ps:scale web=1

You should now be able to view your application on the server. Checking the Logs Heroku keeps a detailed log which can be viewed using the heroku logs command. By passing the tail flag we only see the last 10 lines. For example if you view the URL, the following gets added to the log file.

heroku logs --tail
2015-04-18T18:34:57.199901+00:00 heroku[router]: at=info method=GET path="/" host=marktyers.herokuapp.com request_id=c98d5ee5-afb8-47fd-bf78-05c2ac3d3713 fwd="90.244.82.220" dyno=web.1 connect=2ms service=8ms status=200 bytes=124

3 Running a CI Workflow

Introduction to CI and gitlab Ci

Committing and pushing to trigger the workflow.