Skip to content

Commit 2f2a604

Browse files
author
GenLN
authored
Add files via upload
0 parents  commit 2f2a604

11 files changed

+149
-0
lines changed

Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM centos:centos7
2+
3+
4+
5+
# Install Node etc...
6+
RUN yum -y update; yum clean all
7+
RUN yum -y install epel-release; yum clean all
8+
RUN yum -y install nodejs npm; yum clean all
9+
10+
# Copy source code to /src in container
11+
COPY . /src
12+
13+
# Install app and dependencies into /src in container
14+
RUN cd /src; npm install
15+
16+
# Document the port the app listens on
17+
EXPOSE 8080
18+
19+
# Run this command (starts the app) when the container starts
20+
CMD cd /src && node ./app.js

app.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Simple node.js web app for demonstrating containerizing apps
2+
// For quick demo purposes only (not properly maintained)
3+
'use strict';
4+
5+
var express = require('express'),
6+
app = express();
7+
8+
app.set('views', 'views');
9+
app.set('view engine', 'pug');
10+
11+
app.get('/', function(req, res) {
12+
res.render('home.pug', {
13+
});
14+
});
15+
16+
app.listen(8080);
17+
module.exports.getApp = app;

circle.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# The deployment section should be excluded until
2+
# it is explicitly included in module 5
3+
4+
#deployment:
5+
# dockerhub:
6+
# branch: master
7+
# commands:
8+
# - $DOCKER_HUB_TRIGGER
9+
10+
test:
11+
override:
12+
- mocha

package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "container-web-test",
3+
"private": true,
4+
"version": "0.0.1",
5+
"description": "Demo app for Web container demonstrations",
6+
"main": "app.js",
7+
"author": "Nigel Poulton <[email protected]>",
8+
"license": "Will be full of vulnerabilities!",
9+
"dependencies": {
10+
"express": "4.16.3",
11+
"pug": "2.0.3"
12+
}
13+
}

readme.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Test app for demonstrating containerizing web app
2+
3+
Super-simple Node web app for containerization demos
4+
5+
## Instructions for use
6+
7+
1. Fork the repo
8+
2. Clone repo locally
9+
3. Build Docker iamge `docker image build -t <tag> .` from within the root directory of the repo
10+
4. Push image to container registry
11+
5. Run container/Pod using the created image

test/mocha.opts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--reporter spec

test/test.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Simple async test for HTTP 200 response code using supertest
2+
'use strict';
3+
4+
var request = require("supertest"),
5+
app = require("../app").getApp;
6+
7+
describe('GET /', function(){
8+
it('expects HTTP response 200', function(done){
9+
request(app)
10+
.get('/')
11+
.expect(200, done);
12+
});
13+
});

views/home.pug

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
html
2+
head
3+
title='ACG loves K8S'
4+
link(rel='stylesheet', href='http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css')
5+
body
6+
div.container
7+
div.jumbotron
8+
h1 A Cloud Guru loves Kubernetes!!!
9+
p
10+
p
11+
a.btn.btn-primary(href="https://www.amazon.com/Kubernetes-Book-Nigel-Poulton/dp/1521823634/ref=sr_1_3?ie=UTF8&qid=1531240306&sr=8-3&keywords=nigel+poulton") The Kubernetes Book
12+
p

web-deploy.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: simple-web
5+
labels:
6+
customer: acg
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: web
11+
replicas: 3
12+
strategy:
13+
type: RollingUpdate
14+
template:
15+
metadata:
16+
labels:
17+
app: web
18+
spec:
19+
containers:
20+
- image: nigelpoulton/acg-web:0.1
21+
name: web-ctr
22+
ports:
23+
- containerPort: 8080

web-lb.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: web-svc
5+
labels:
6+
app: web
7+
spec:
8+
type: LoadBalancer
9+
ports:
10+
- port: 80
11+
targetPort: 8080
12+
selector:
13+
app: web

web-nodeport.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: web-nodeport
5+
labels:
6+
app: web
7+
spec:
8+
type: NodePort
9+
ports:
10+
- port: 8080
11+
nodePort: 31000
12+
selector:
13+
app: web
14+

0 commit comments

Comments
 (0)