Skip to content
Permalink
Browse files
Added Notes to DevOps Lab
  • Loading branch information
aa7401 committed Nov 18, 2019
1 parent d2ff9bd commit 27b329da91a334538781079babbaf194858bc2e3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
@@ -17,15 +17,45 @@ Once cloned you need to _mirror push_ to the empty gitlab repository.
cd temp/ && git push --mirror xxx
```

## 2 Deploying to the Cloud
If you get an error at this point you need to use the following technique:

```shell
$ git remote set-url origin https://gitlab.com/xxx/devops.git
$ git push origin master
```

Change `xxx` to your username.

Now delete the temporary local repository.

```shell
cd .. && rm -rf temp
```

Now you can clone the repository from the GitLab repository.

## 1 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.
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 Terminal window.

### 1.1 Configuring the App

There are a few changes that need to be made to the code before you attempt to deploy it to the cloud server. The first is to understand that the cloud service will determine which port your app will need to run on which is mapped to the URL. To enable this, the remote server instance will have an environment variable called `PORT` set and you need to check for this before setting the port the app will use. If you study the `index.js` file in the `template-dynamic-website` template you will find the following two lines of code:

```javascript
const defaultPort = 8080
const port = process.env.PORT || defaultPort
```

This defines a default port for the app to run on. The second line assigns the value in the `PORT` environment variable to the `port` variable and, if this is not available assigns the default port.

The second issue is that the cloud service will automatically be installing the module dependencies with no intervention from you. This means that these must all be listed in the `dependencies` key in your _package manifest_ `package.json`.

### 2.1 Configuring the Server
### 1.2 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](https://devcenter.heroku.com/articles/heroku-cli) on their website.
We will be interacting with Heroku using a command-line utility. Open up the Terminal window and install it using the [detailed instructions](https://devcenter.heroku.com/articles/heroku-cli) on their website.

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

@@ -53,11 +83,11 @@ 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)
origin https://github.coventry.ac.uk/xxx/xxx.git (fetch)
origin https://github.coventry.ac.uk/xxx/xxx.git (push)
```

### 2.2 Deploying to Heroku
### 1.3 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:

@@ -82,8 +112,8 @@ 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
## 2 Continuous Integration

Introduction to CI and gitlab Ci
Continuous integration is the process of regularly merging code changes into the central repository. For this to work all code must be regularly checked for issues using a range of automated tools. As of the time of writing GitHub have an integrated CI tool called **Github Actions** however this is still in beta. For this lab you will be using the CI tools that are built into GitLab which is why you have already mirrored the test code to a repository on the GitLab server.

Committing and pushing to trigger the workflow.
@@ -19,7 +19,7 @@
"global": {
"branches": 0,
"functions": 0,
"lines":0,
"lines": 0,
"statements": 0
}
}
@@ -40,6 +40,7 @@
"koa-static": "^5.0.0",
"koa-views": "^6.1.5",
"mime-types": "^2.1.22",
"npm-check": "^5.9.0",
"sqlite-async": "^1.0.11"
},
"devDependencies": {

0 comments on commit 27b329d

Please sign in to comment.