SlideShare una empresa de Scribd logo
1 de 73
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 42
The QEWD Docker Appliance
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
Docker?
• A technology that allows software to be
encapsulated inside an isolated container
• According to Docker themselves:
– "Docker containers wrap a piece of software in a
complete filesystem that contains everything needed
to run: code, runtime, system tools, system libraries –
anything that can be installed on a server. This
guarantees that the software will always run the
same, regardless of its environment."
– See https://www.docker.com/what-docker
Copyright © 2016 M/Gateway Developments Ltd
QEWD Docker Container
• QEWD is available from the main docker.io
repository as a pre-built Docker container
– rtweed/qewd
• You can also build your own version using the
Dockerfile that is included in the QEWD
repository
– eg, if you wanted to apply your own customisations
– See https://github.com/robtweed/qewd/blob/master/docker/Dockerfile
Copyright © 2016 M/Gateway Developments Ltd
Benefits of the QEWD Container
• Provided you've installed Docker, you
don't need to do any further installation
– Just run the container
• First time you do this, it will automatically download
it from docker.io
Copyright © 2016 M/Gateway Developments Ltd
Benefits of the QEWD Container
• QEWD functionality without any "moving
parts" on your system
– eg no Node.js dependency clashes
• You don't even need Node.js installed on your
system
– You just define your handler modules
• Write JavaScript files and let the QEWD container
handle them
– Without Node.js having to even be present on your
system
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• Just the core QEWD engine
– Master process
– Worker processes
• Doesn't include the embedded database
– Currently designed to work with Redis only
• Using mapped volumes
– You can use Redis locally, in another
container or remotely
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• Normal QEWD Session management will
take place provided a Redis database is
available
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• Nothing you can do in a standard local
QEWD installation that can't also be
achieved by using the Dockerised version
– There's even a version for the Raspberry Pi!
• rtweed/rpi-qewd
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• "Out of the box" defaults
– Management password: 'keepThisSecret!'
– Worker pool size: 1
– Database: Redis listening on port 6379
• qewd-monitor application is included and
ready to run
– No other applications or APIs pre-defined
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• You can customise the configuration:
– Management password
– Server name (what appears in qewd-monitor's
banner)
– Worker pool size
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• By using Docker volume mapping, you can
make specific directories in your host
system available to the QEWD Docker
container
• In your host system you can therefore
define interactive QEWD applications:
– Static browser-side resources (HTML, JS,
CSS files)
– Back-end handler modules
Copyright © 2016 M/Gateway Developments Ltd
QEWD Appliance
• You can also define routes within your host
system, to be used by the QEWD
Appliance
– For Web / REST service APIs
Copyright © 2016 M/Gateway Developments Ltd
So let's try it out
• I'm going to use a Ubuntu Linux system
• However, Docker can be installed on most
platforms
– Windows
– Linux (all versions/flavours)
– Unix
– MacOS
– Even the Raspberry Pi!
Copyright © 2016 M/Gateway Developments Ltd
Installing Docker on Ubuntu 16.04
• sudo apt-get update
• sudo apt-get install docker.io
• You can now use Docker
– By default, you'll need to run Docker
commands as sudo
– This can be modified. See:
– https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
Copyright © 2016 M/Gateway Developments Ltd
Installing Docker on Raspberry Pi
• Just invoke the command:
curl -sSL https://get.docker.com | sh
• You can now use Docker on your
Raspberry Pi
– By default, you'll need to run Docker
commands as sudo
Copyright © 2016 M/Gateway Developments Ltd
Some Quick Docker Tests
• Try running these to confirm that Docker is
properly installed and working on your
system:
– sudo docker version
– sudo docker info
Copyright © 2016 M/Gateway Developments Ltd
Let's start a Redis Container
On Linux:
• sudo docker run -d --name redis -p 6379:6379 redis
• Runs as a daemon (-d)
• Exposes internal port 6379 (the default Redis port)
externally to the host as port 6379 (-p)
• First time you invoke this command, it will download and
install the Redis Docker container
Copyright © 2016 M/Gateway Developments Ltd
Let's start a Redis Container
On Raspberry Pi:
• sudo docker run -d --name redis -p 6379:6379 hypriot/rpi-redis
• Runs as a daemon (-d)
• Exposes internal port 6379 (the default Redis port)
externally to the host as port 6379 (-p)
• First time you invoke this command, it will download and
install the Redis Docker container
Copyright © 2016 M/Gateway Developments Ltd
Test Redis
• First install the Redis command line tool:
– sudo apt-get install redis-tools
• Now start the Redis command line:
redis-cli
• It should respond with
127.0.0.1:6379>
– it's working and you're connected to the Redis container!
• Try the command:
info
• Exit redis-cli by typing CTRL&C
Copyright © 2016 M/Gateway Developments Ltd
Prepare for the QEWD Appliance
• First important step:
– Create a directory for mapping the QEWD working
directory
– It can be any directory you like. I'll use:
cd ~
mkdir qewd
– Now make a sub-directory named modules
cd qewd
mkdir modules
• You don't need to put anything into this directory
yet, but it should exist
Copyright © 2016 M/Gateway Developments Ltd
Start the QEWD Appliance
sudo docker run -d -p 8080:8080 --link redis:redis -v /home/ubuntu/qewd/modules:/opt/qewd/mapped rtweed/qewd
First time you invoke this, it will download the QEWD Container from
Docker.io
-p 8080:8080 maps port 8080 in the QEWD container to your host's port 8080
-d run as a daemon. You can also try -it for interactive display
-link redis:redis links to the Redis container
-v maps the QEWD working directory to the one we created
QEWD will now be running!
On Linux:
Copyright © 2016 M/Gateway Developments Ltd
Start the QEWD Appliance
sudo docker run -d -p 8080:8080 --link redis:redis -v /home/pi/qewd/modules:/opt/qewd/mapped rtweed/rpi-qewd
First time you invoke this, it will download the QEWD Container from
Docker.io
-p 8080:8080 maps port 8080 in the QEWD container to your host's port 8080
-d run as a daemon. You can also try -it for interactive display
-link redis:redis links to the Redis container
-v maps the QEWD working directory to the one we created
QEWD will now be running!
On Raspberry Pi:
Copyright © 2016 M/Gateway Developments Ltd
Try QEWD
http://192.168.1.123:8080/qewd-monitor/index.html
Change the IP address / host name as appropriate for your host machine
You should see the qewd-monitor application!
Log in using the default password: keepThisSecret!
Copyright © 2016 M/Gateway Developments Ltd
Let's check Redis again
• Start redis-cli again
• This time enter the command:
– keys *
• You should see a load of Redis key/value
pairs, representing the QEWD Session
global storage used by your qewd-monitor
session
Copyright © 2016 M/Gateway Developments Ltd
Let's build a quick application
• We'll create the files in the ~/qewd
directory that we previously made
Copyright © 2016 M/Gateway Developments Ltd
First, stop the QEWD Container
• Use the qewd-monitor; or
• Use the docker stop command
– To do that we need to first find out the QEWD
container's unique Id
– sudo docker ps -a
CONTAINER ID IMAGE
d810c520894e rtweed/qewd
7d0c18b8cec5 redis
Copyright © 2016 M/Gateway Developments Ltd
First, stop the QEWD Container
• Use the qewd-monitor; or
• Use the docker stop command
– To do that we need to first find out the QEWD
container's unique Id
– sudo docker ps -a
CONTAINER ID IMAGE
d810c520894e rtweed/qewd
7d0c18b8cec5 redis Usually the first
3 characters are
sufficient
Copyright © 2016 M/Gateway Developments Ltd
Stop the QEWD Container
• sudo docker stop d81
Copyright © 2016 M/Gateway Developments Ltd
Create a test application
• We'll name it testapp
– It will have a button which, when clicked,
sends a message to the QEWD back-end
which returns an acknowledgement response
• First create a directory for the browser-
side static files:
cd ~/qewd
mkdir www
cd www
Copyright © 2016 M/Gateway Developments Ltd
Create the index.html
<html>
<head>
<title>Demo QEWD application</title>
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/ewd-client.js"></script>
<script src="app.js"></script>
<button id="testBtn">Click Me</button>
<div id="content">
Content goes here
</div>
</body>
</html> Save as ~/qewd/www/testapp/index.html
Copyright © 2016 M/Gateway Developments Ltd
Create the app.js
Save as ~/qewd/www/testapp/app.js
$(document).ready(function() {
EWD.log = true;
EWD.on('ewd-registered', function() {
$('#testBtn').on('click', function(e) {
var message = {type: 'testButton'};
EWD.send(message, function(messageObj) {
$('#content').text(messageObj.message.ok);
});
});
});
EWD.start('testapp', $, io);
});
Copyright © 2016 M/Gateway Developments Ltd
Create the back-end module
• This needs to go into the directory we
created earlier:
~/qewd/modules
• We'll name the module testapp.js
Copyright © 2016 M/Gateway Developments Ltd
Create testapp.js
module.exports = {
handlers: {
testButton: function(messageObj, session, send, finished) {
console.log('*** handling the button click message!');
session.data.$('foo').value = 'bar';
finished({
ok: 'testButton message was processed successfully!'
});
}
}
};
Save as ~/qewd/modules/testapp.js
Copyright © 2016 M/Gateway Developments Ltd
How will QEWD find the module?
• The QEWD Docker Appliance will expect
to find it in its node_modules directory
• We don't have access to that from the host
• But we've mapped ~/qewd/modules to a
mapped volume in the Docker container:
~/opt/qewd/mapped
Copyright © 2016 M/Gateway Developments Ltd
How will QEWD find the module?
• We can use a QEWD module map to tell
QEWD where to find the back-end module
for our testapp application
• The QEWD Docker appliance allows us to
define this in the mapped volume directory
using the reserved file name:
– moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Create moduleMap.js
module.exports = {
testapp: '/opt/qewd/mapped/testapp'
}
Save as ~/qewd/modules/moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Create moduleMap.js
module.exports = {
testapp: '/opt/qewd/mapped/testapp'
}
The module map exports as many mappings as you want
Save as ~/qewd/modules/moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Create moduleMap.js
module.exports = {
testapp: '/opt/qewd/mapped/testapp'
}
The module map exports as many mappings as you want
We just need this one.
Save as ~/qewd/modules/moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Create moduleMap.js
module.exports = {
testapp: '/opt/qewd/mapped/testapp'
}
Note: the mapped module path is to the internal path
within the container
Save as ~/qewd/modules/moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Create moduleMap.js
module.exports = {
testapp: '/opt/qewd/mapped/testapp'
}
Note: the mapped module path is to the internal path
within the container, not the path we created on the host
~/qewd/modules/testapp.js
Copyright © 2016 M/Gateway Developments Ltd
That should be all we need
• When we start the QEWD Appliance
again, we must also map the directory
containing the browser-side files, ie
– ~/qewd/www/testapp
Copyright © 2016 M/Gateway Developments Ltd
Start the QEWD Appliance
• On Linux:
sudo docker run -d -p 8080:8080 --link redis:redis ↩
-v /home/ubuntu/qewd/modules:/opt/qewd/mapped ↩
-v /home/ubuntu/qewd/www/testapp:/opt/qewd/www/testapp ↩
rtweed/qewd
Copyright © 2016 M/Gateway Developments Ltd
Start the QEWD Appliance
• On Raspberry Pi:
sudo docker run -d -p 8080:8080 --link redis:redis ↩
-v /home/pi/qewd/modules:/opt/qewd/mapped ↩
-v /home/pi/qewd/www/testapp:/opt/qewd/www/testapp ↩
rtweed/rpi-qewd
Copyright © 2016 M/Gateway Developments Ltd
Try running testapp
It works
The console show that
testapp correctly registered
itself on QEWD
Try clicking the button..
Copyright © 2016 M/Gateway Developments Ltd
Try running testapp
It works too!
A message was sent
to the QEWD back-end
which returned the expected
response
Copyright © 2016 M/Gateway Developments Ltd
Check the Session
Start the qewd-monitor application and click the Session tab:
Copyright © 2016 M/Gateway Developments Ltd
Check the Session
Start the qewd-monitor application and click the Session tab:
Where did this come from?
Copyright © 2016 M/Gateway Developments Ltd
It came from testapp.js
module.exports = {
handlers: {
testButton: function(messageObj, session, send, finished) {
console.log('*** handling the button click message!');
session.data.$('foo').value = 'bar';
finished({
ok: 'testButton message was processed successfully!'
});
}
}
};
Save as ~/qewd/modules/testapp.js
Copyright © 2016 M/Gateway Developments Ltd
QEWD Apps with no moving parts!
• We just created a QEWD app without
having anything installed other than
Docker
• We just defined:
– the HTML and JavaScript files for the
browser
– The back-end JavaScript handler module
• And mapped their directories as Docker
volumes
Copyright © 2016 M/Gateway Developments Ltd
Adding more apps
• Each app you create will need its own
subdirectory under the ~/qewd/www directory
– For its browser-side HTML, JavaScript, etc files
– Each of these will have to be mapped to the
corresponding volume in the QEWD container
• Their back-end modules, however, just go into
your mapped ~/qewd/modules folder
– And then define their module mapping in
moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Mapping Multiple Apps
module.exports = {
testapp: '/opt/qewd/mapped/testapp',
mySecondApp: '/opt/qewd/mapped/mySecondApp',
myThirdApp: '/opt/qewd/mapped/myThirdApp'
}
~/qewd/modules/moduleMap.js
Copyright © 2016 M/Gateway Developments Ltd
Mapping Multiple Apps
• eg, On Linux:
sudo docker run -d -p 8080:8080 --link redis:redis ↩
-v /home/ubuntu/qewd/modules:/opt/qewd/mapped ↩
-v /home/ubuntu/qewd/www/testapp:/opt/qewd/www/testapp ↩
-v /home/ubuntu/qewd/www/mySecondApp:/opt/qewd/www/mySecondApp ↩
-v /home/ubuntu/qewd/www/myThirdApp:/opt/qewd/www/myThirdApp ↩
rtweed/qewd
Copyright © 2016 M/Gateway Developments Ltd
What about REST APIs?
• We can use the QEWD Docker Appliance
to very quickly create REST APIs, again
without any moving parts other than
Docker itself
• Even simpler to create than applications
Copyright © 2016 M/Gateway Developments Ltd
Let's create an API
• We'll define a URL path prefix:
– /api
• And handle any lower-level URLs, eg:
– /api/test
• To do this we just need to create a handler
module for the /api path. We'll call it api.js. It
must be saved into the ~/qewd/modules
directory
Copyright © 2016 M/Gateway Developments Ltd
Create api.js
module.exports = {
restModule: true,
handlers: {
test: function(messageObj, finished) {
finished({foo: 'bar'});
}
}
};
Save as ~/qewd/modules/api.js
Copyright © 2016 M/Gateway Developments Ltd
Create api.js
module.exports = {
restModule: true,
handlers: {
test: function(messageObj, finished) {
finished({foo: 'bar'});
}
}
};
Save as ~/qewd/modules/api.js
It's just a standard QEWD REST/Web Service Module
Copyright © 2016 M/Gateway Developments Ltd
Create api.js
module.exports = {
restModule: true,
handlers: {
test: function(messageObj, finished) {
finished({foo: 'bar'});
}
}
};
This function, test, will handle
any incoming /api/test requests
Copyright © 2016 M/Gateway Developments Ltd
QEWD needs to know how to find it
• As we're defining the handler module in a
mapped directory, we need to tell QEWD
where to find it and how to define it as a
route.
• For this we define a reserved named file in
our ~/qewd/modules directory:
– routes.js
Copyright © 2016 M/Gateway Developments Ltd
Create routes.js
module.exports = [
{
path: '/api',
module: '/opt/qewd/mapped/api'
}
];
Save as ~/qewd/modules/routes.js
Copyright © 2016 M/Gateway Developments Ltd
Create routes.js
module.exports = [
{
path: '/api',
module: '/opt/qewd/mapped/api'
}
];
Save as ~/qewd/modules/routes.js
You export an array of route objects
We'll just define one for /api in this example,
but you can define as many routes as you wish
Copyright © 2016 M/Gateway Developments Ltd
Create routes.js
module.exports = [
{
path: '/api',
module: '/opt/qewd/mapped/api'
}
];
Note that the route must map to the container's
internal mapped volume path
So any incoming requests with a URL starting
/api will be handled by the api.js file we've created
in the host's mapped directory
Copyright © 2016 M/Gateway Developments Ltd
Let's try it
• Our handler function isn't making any
distinctions about the HTTP method used,
so we can test it just using a browser.
Copyright © 2016 M/Gateway Developments Ltd
Let's try it
It worked!
Copyright © 2016 M/Gateway Developments Ltd
REST/Web Service APIs
• Of course this was a very simple example
• But you can write as complex APIs as you
wish.
• All the functionality described in parts 31
and 36 of this course are available in the
QEWD Docker Appliance
Copyright © 2016 M/Gateway Developments Ltd
REST APIs without moving parts
• You can now define Web/REST APIs by
writing JavaScript handler module files
• No need to install Node.js
Copyright © 2016 M/Gateway Developments Ltd
Customising QEWD Appliance
• QEWD Docker Appliance defaults:
– Management password: keepThisSecret!
• Always a good idea to change this!
– Server name: QEWD Docker Server
• Used by the qewd-monitor application
– Worker pool size: 1
• You can change these
Copyright © 2016 M/Gateway Developments Ltd
Customising QEWD Appliance
• Create a file named custom.js in your
mapped directory (eg ~/qewd/mapped)
– custom.js is a reserved name that the QEWD
Docker Appliance will look for and use for
customising its configuration
Copyright © 2016 M/Gateway Developments Ltd
Create custom.js
module.exports = {
config: {
managementPassword: 'mySecret!',
serverName: 'Robs QEWD Docker Appliance',
poolSize: 2
}
};
Save as ~/qewd/modules/custom.js
Copyright © 2016 M/Gateway Developments Ltd
Restart the Appliance
• eg:
– sudo docker restart d81
• Try running qewd-monitor
– You'll need to use your new custom login
password
– It will display the new name for your server
– It will show 2 worker processes
Copyright © 2016 M/Gateway Developments Ltd
Further Customisation
• You can get access to the master process
objects:
– Create user defined data / objects that are
passed to worker processes
– Access the ewd-qoper8 object
– Access the Express object
• Define a run function. This is invoked
when QEWD starts.
Copyright © 2016 M/Gateway Developments Ltd
Create custom.js
function customise(config, q, intercept) {
console.log('*** This is the custom function calling!');
}
module.exports = {
config: {
run: customise,
managementPassword: 'mySecret!',
serverName: 'Robs QEWD Docker Appliance',
poolSize: 2
}
};
Save as ~/qewd/modules/custom.js
Copyright © 2016 M/Gateway Developments Ltd
Create custom.js
function customise(config, q, intercept) {
console.log('*** This is the custom function calling!');
}
module.exports = {
config: {
run: customise,
managementPassword: 'mySecret!',
serverName: 'Robs QEWD Docker Appliance',
poolSize: 2
}
}; q is the main ewd-qoper8 object
intercept.app is the Express object
allowing you to add custom middleware
Copyright © 2016 M/Gateway Developments Ltd
That's the QEWD Docker Appliance
• A handy and simple, low-impact way of
using QEWD without worrying about
interactions with your existing set-up
– And without having to install Node.js or a
database
• All the functionality of a standard local
implementation of QEWD is still available
to you

Más contenido relacionado

La actualidad más candente

ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
Tetsuyuki Kobayashi
 
Introduction To Google Chrome Os
Introduction To Google Chrome OsIntroduction To Google Chrome Os
Introduction To Google Chrome Os
Saurabh Jinturkar
 

La actualidad más candente (20)

What is Docker
What is DockerWhat is Docker
What is Docker
 
Google Chrome OS
Google Chrome OSGoogle Chrome OS
Google Chrome OS
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
 
IBM informix: compared performance efficiency between physical server and Vir...
IBM informix: compared performance efficiency between physical server and Vir...IBM informix: compared performance efficiency between physical server and Vir...
IBM informix: compared performance efficiency between physical server and Vir...
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Server Management
Server ManagementServer Management
Server Management
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device Drivers
 
Introduction To Google Chrome Os
Introduction To Google Chrome OsIntroduction To Google Chrome Os
Introduction To Google Chrome Os
 
OpenShift 4버전의 변경사항 및 OPENMARU APM의 CoreOS, CRI-O 모니터링 기능
OpenShift 4버전의 변경사항 및 OPENMARU APM의 CoreOS, CRI-O 모니터링 기능OpenShift 4버전의 변경사항 및 OPENMARU APM의 CoreOS, CRI-O 모니터링 기능
OpenShift 4버전의 변경사항 및 OPENMARU APM의 CoreOS, CRI-O 모니터링 기능
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Load Testing - How to Stress Your Odoo with Locust
Load Testing - How to Stress Your Odoo with LocustLoad Testing - How to Stress Your Odoo with Locust
Load Testing - How to Stress Your Odoo with Locust
 
Ceph with CloudStack
Ceph with CloudStackCeph with CloudStack
Ceph with CloudStack
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
Kubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard wayKubernetes at Datadog the very hard way
Kubernetes at Datadog the very hard way
 
Manejo de packages en Kubernetes con Helm
Manejo de packages en Kubernetes con HelmManejo de packages en Kubernetes con Helm
Manejo de packages en Kubernetes con Helm
 
Microsoft Hyper-V explained
Microsoft Hyper-V explainedMicrosoft Hyper-V explained
Microsoft Hyper-V explained
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
operating system
operating systemoperating system
operating system
 
Quick introduction to Qwik
Quick introduction to QwikQuick introduction to Qwik
Quick introduction to Qwik
 

Destacado

Destacado (20)

EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 34: QEWD Resilient ModeEWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 34: QEWD Resilient Mode
 
EWD 3 Training Course Part 29: Running QEWD as a Service
EWD 3 Training Course Part 29: Running QEWD as a ServiceEWD 3 Training Course Part 29: Running QEWD as a Service
EWD 3 Training Course Part 29: Running QEWD as a Service
 
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD ApplicationsEWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD Applications
 
EWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 26: Event-driven IndexingEWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 26: Event-driven Indexing
 
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 31: Using QEWD for Web and REST ServicesEWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
 
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWDEWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD
 
EWD 3 Training Course Part 2: EWD 3 Overview
EWD 3 Training Course Part 2: EWD 3 OverviewEWD 3 Training Course Part 2: EWD 3 Overview
EWD 3 Training Course Part 2: EWD 3 Overview
 
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 24: Traversing a Document's Leaf NodesEWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
 
EWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 25: Document Database CapabilitiesEWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 25: Document Database Capabilities
 
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript ObjectsEWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript Objects
 
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5a: First Steps in Building a QEWD ApplicationEWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5a: First Steps in Building a QEWD Application
 
EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode ObjectEWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode Object
 
EWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 19: The cache.node APIsEWD 3 Training Course Part 19: The cache.node APIs
EWD 3 Training Course Part 19: The cache.node APIs
 
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPSEWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
 
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5b: First Steps in Building a QEWD ApplicationEWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
 
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
 
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
 
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode ObjectsEWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
EWD 3 Training Course Part 22: Traversing Documents using DocumentNode Objects
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
 

Similar a EWD 3 Training Course Part 42: The QEWD Docker Appliance

Docker workshop
Docker workshopDocker workshop
Docker workshop
Evans Ye
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 

Similar a EWD 3 Training Course Part 42: The QEWD Docker Appliance (20)

Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
 
GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins
GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins
GDG-ANDROID-ATHENS Meetup: Build in Docker with Jenkins
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016
 
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
 
Docker 101 @KACST Saudi HPC 2016
Docker 101  @KACST Saudi HPC 2016Docker 101  @KACST Saudi HPC 2016
Docker 101 @KACST Saudi HPC 2016
 
How Reconnix Is Using Docker
How Reconnix Is Using DockerHow Reconnix Is Using Docker
How Reconnix Is Using Docker
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Docker engine - Indroduc
Docker engine - IndroducDocker engine - Indroduc
Docker engine - Indroduc
 
VMware@Night Container and Virtualization
VMware@Night Container and VirtualizationVMware@Night Container and Virtualization
VMware@Night Container and Virtualization
 
VMware@Night: Container & Virtualisierung
VMware@Night: Container & VirtualisierungVMware@Night: Container & Virtualisierung
VMware@Night: Container & Virtualisierung
 
Kubernetes Story - Day 1: Build and Manage Containers with Podman
Kubernetes Story - Day 1: Build and Manage Containers with PodmanKubernetes Story - Day 1: Build and Manage Containers with Podman
Kubernetes Story - Day 1: Build and Manage Containers with Podman
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
Rally_Docker_deployment_JumpVM
Rally_Docker_deployment_JumpVMRally_Docker_deployment_JumpVM
Rally_Docker_deployment_JumpVM
 
Deploy django apps using docker
Deploy django apps using dockerDeploy django apps using docker
Deploy django apps using docker
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Cicd.pdf
Cicd.pdfCicd.pdf
Cicd.pdf
 
Containerizing Web Application with Docker
Containerizing Web Application with DockerContainerizing Web Application with Docker
Containerizing Web Application with Docker
 

Más de Rob Tweed

Más de Rob Tweed (17)

QEWD Update
QEWD UpdateQEWD Update
QEWD Update
 
Data Persistence as a Language Feature
Data Persistence as a Language FeatureData Persistence as a Language Feature
Data Persistence as a Language Feature
 
LNUG: Having Your Node.js Cake and Eating It Too
LNUG: Having Your Node.js Cake and Eating It TooLNUG: Having Your Node.js Cake and Eating It Too
LNUG: Having Your Node.js Cake and Eating It Too
 
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService FunctionalityEWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
 
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.jsEWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
 
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST ServicesEWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
 
QEWD.js, JSON Web Tokens & MicroServices
QEWD.js, JSON Web Tokens & MicroServicesQEWD.js, JSON Web Tokens & MicroServices
QEWD.js, JSON Web Tokens & MicroServices
 
QEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It TooQEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It Too
 
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Servicesewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
 
qewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tierqewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tier
 
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
 
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
 
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
 
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 35: QEWD Session LockingEWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 35: QEWD Session Locking
 
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORSEWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
 
EWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 27: The QEWD SessionEWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 27: The QEWD Session
 
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode ObjectsEWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 

EWD 3 Training Course Part 42: The QEWD Docker Appliance

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 42 The QEWD Docker Appliance Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd Docker? • A technology that allows software to be encapsulated inside an isolated container • According to Docker themselves: – "Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment." – See https://www.docker.com/what-docker
  • 3. Copyright © 2016 M/Gateway Developments Ltd QEWD Docker Container • QEWD is available from the main docker.io repository as a pre-built Docker container – rtweed/qewd • You can also build your own version using the Dockerfile that is included in the QEWD repository – eg, if you wanted to apply your own customisations – See https://github.com/robtweed/qewd/blob/master/docker/Dockerfile
  • 4. Copyright © 2016 M/Gateway Developments Ltd Benefits of the QEWD Container • Provided you've installed Docker, you don't need to do any further installation – Just run the container • First time you do this, it will automatically download it from docker.io
  • 5. Copyright © 2016 M/Gateway Developments Ltd Benefits of the QEWD Container • QEWD functionality without any "moving parts" on your system – eg no Node.js dependency clashes • You don't even need Node.js installed on your system – You just define your handler modules • Write JavaScript files and let the QEWD container handle them – Without Node.js having to even be present on your system
  • 6. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • Just the core QEWD engine – Master process – Worker processes • Doesn't include the embedded database – Currently designed to work with Redis only • Using mapped volumes – You can use Redis locally, in another container or remotely
  • 7. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • Normal QEWD Session management will take place provided a Redis database is available
  • 8. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • Nothing you can do in a standard local QEWD installation that can't also be achieved by using the Dockerised version – There's even a version for the Raspberry Pi! • rtweed/rpi-qewd
  • 9. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • "Out of the box" defaults – Management password: 'keepThisSecret!' – Worker pool size: 1 – Database: Redis listening on port 6379 • qewd-monitor application is included and ready to run – No other applications or APIs pre-defined
  • 10. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • You can customise the configuration: – Management password – Server name (what appears in qewd-monitor's banner) – Worker pool size
  • 11. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • By using Docker volume mapping, you can make specific directories in your host system available to the QEWD Docker container • In your host system you can therefore define interactive QEWD applications: – Static browser-side resources (HTML, JS, CSS files) – Back-end handler modules
  • 12. Copyright © 2016 M/Gateway Developments Ltd QEWD Appliance • You can also define routes within your host system, to be used by the QEWD Appliance – For Web / REST service APIs
  • 13. Copyright © 2016 M/Gateway Developments Ltd So let's try it out • I'm going to use a Ubuntu Linux system • However, Docker can be installed on most platforms – Windows – Linux (all versions/flavours) – Unix – MacOS – Even the Raspberry Pi!
  • 14. Copyright © 2016 M/Gateway Developments Ltd Installing Docker on Ubuntu 16.04 • sudo apt-get update • sudo apt-get install docker.io • You can now use Docker – By default, you'll need to run Docker commands as sudo – This can be modified. See: – https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
  • 15. Copyright © 2016 M/Gateway Developments Ltd Installing Docker on Raspberry Pi • Just invoke the command: curl -sSL https://get.docker.com | sh • You can now use Docker on your Raspberry Pi – By default, you'll need to run Docker commands as sudo
  • 16. Copyright © 2016 M/Gateway Developments Ltd Some Quick Docker Tests • Try running these to confirm that Docker is properly installed and working on your system: – sudo docker version – sudo docker info
  • 17. Copyright © 2016 M/Gateway Developments Ltd Let's start a Redis Container On Linux: • sudo docker run -d --name redis -p 6379:6379 redis • Runs as a daemon (-d) • Exposes internal port 6379 (the default Redis port) externally to the host as port 6379 (-p) • First time you invoke this command, it will download and install the Redis Docker container
  • 18. Copyright © 2016 M/Gateway Developments Ltd Let's start a Redis Container On Raspberry Pi: • sudo docker run -d --name redis -p 6379:6379 hypriot/rpi-redis • Runs as a daemon (-d) • Exposes internal port 6379 (the default Redis port) externally to the host as port 6379 (-p) • First time you invoke this command, it will download and install the Redis Docker container
  • 19. Copyright © 2016 M/Gateway Developments Ltd Test Redis • First install the Redis command line tool: – sudo apt-get install redis-tools • Now start the Redis command line: redis-cli • It should respond with 127.0.0.1:6379> – it's working and you're connected to the Redis container! • Try the command: info • Exit redis-cli by typing CTRL&C
  • 20. Copyright © 2016 M/Gateway Developments Ltd Prepare for the QEWD Appliance • First important step: – Create a directory for mapping the QEWD working directory – It can be any directory you like. I'll use: cd ~ mkdir qewd – Now make a sub-directory named modules cd qewd mkdir modules • You don't need to put anything into this directory yet, but it should exist
  • 21. Copyright © 2016 M/Gateway Developments Ltd Start the QEWD Appliance sudo docker run -d -p 8080:8080 --link redis:redis -v /home/ubuntu/qewd/modules:/opt/qewd/mapped rtweed/qewd First time you invoke this, it will download the QEWD Container from Docker.io -p 8080:8080 maps port 8080 in the QEWD container to your host's port 8080 -d run as a daemon. You can also try -it for interactive display -link redis:redis links to the Redis container -v maps the QEWD working directory to the one we created QEWD will now be running! On Linux:
  • 22. Copyright © 2016 M/Gateway Developments Ltd Start the QEWD Appliance sudo docker run -d -p 8080:8080 --link redis:redis -v /home/pi/qewd/modules:/opt/qewd/mapped rtweed/rpi-qewd First time you invoke this, it will download the QEWD Container from Docker.io -p 8080:8080 maps port 8080 in the QEWD container to your host's port 8080 -d run as a daemon. You can also try -it for interactive display -link redis:redis links to the Redis container -v maps the QEWD working directory to the one we created QEWD will now be running! On Raspberry Pi:
  • 23. Copyright © 2016 M/Gateway Developments Ltd Try QEWD http://192.168.1.123:8080/qewd-monitor/index.html Change the IP address / host name as appropriate for your host machine You should see the qewd-monitor application! Log in using the default password: keepThisSecret!
  • 24. Copyright © 2016 M/Gateway Developments Ltd Let's check Redis again • Start redis-cli again • This time enter the command: – keys * • You should see a load of Redis key/value pairs, representing the QEWD Session global storage used by your qewd-monitor session
  • 25. Copyright © 2016 M/Gateway Developments Ltd Let's build a quick application • We'll create the files in the ~/qewd directory that we previously made
  • 26. Copyright © 2016 M/Gateway Developments Ltd First, stop the QEWD Container • Use the qewd-monitor; or • Use the docker stop command – To do that we need to first find out the QEWD container's unique Id – sudo docker ps -a CONTAINER ID IMAGE d810c520894e rtweed/qewd 7d0c18b8cec5 redis
  • 27. Copyright © 2016 M/Gateway Developments Ltd First, stop the QEWD Container • Use the qewd-monitor; or • Use the docker stop command – To do that we need to first find out the QEWD container's unique Id – sudo docker ps -a CONTAINER ID IMAGE d810c520894e rtweed/qewd 7d0c18b8cec5 redis Usually the first 3 characters are sufficient
  • 28. Copyright © 2016 M/Gateway Developments Ltd Stop the QEWD Container • sudo docker stop d81
  • 29. Copyright © 2016 M/Gateway Developments Ltd Create a test application • We'll name it testapp – It will have a button which, when clicked, sends a message to the QEWD back-end which returns an acknowledgement response • First create a directory for the browser- side static files: cd ~/qewd mkdir www cd www
  • 30. Copyright © 2016 M/Gateway Developments Ltd Create the index.html <html> <head> <title>Demo QEWD application</title> </head> <body> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script src="/socket.io/socket.io.js"></script> <script src="/ewd-client.js"></script> <script src="app.js"></script> <button id="testBtn">Click Me</button> <div id="content"> Content goes here </div> </body> </html> Save as ~/qewd/www/testapp/index.html
  • 31. Copyright © 2016 M/Gateway Developments Ltd Create the app.js Save as ~/qewd/www/testapp/app.js $(document).ready(function() { EWD.log = true; EWD.on('ewd-registered', function() { $('#testBtn').on('click', function(e) { var message = {type: 'testButton'}; EWD.send(message, function(messageObj) { $('#content').text(messageObj.message.ok); }); }); }); EWD.start('testapp', $, io); });
  • 32. Copyright © 2016 M/Gateway Developments Ltd Create the back-end module • This needs to go into the directory we created earlier: ~/qewd/modules • We'll name the module testapp.js
  • 33. Copyright © 2016 M/Gateway Developments Ltd Create testapp.js module.exports = { handlers: { testButton: function(messageObj, session, send, finished) { console.log('*** handling the button click message!'); session.data.$('foo').value = 'bar'; finished({ ok: 'testButton message was processed successfully!' }); } } }; Save as ~/qewd/modules/testapp.js
  • 34. Copyright © 2016 M/Gateway Developments Ltd How will QEWD find the module? • The QEWD Docker Appliance will expect to find it in its node_modules directory • We don't have access to that from the host • But we've mapped ~/qewd/modules to a mapped volume in the Docker container: ~/opt/qewd/mapped
  • 35. Copyright © 2016 M/Gateway Developments Ltd How will QEWD find the module? • We can use a QEWD module map to tell QEWD where to find the back-end module for our testapp application • The QEWD Docker appliance allows us to define this in the mapped volume directory using the reserved file name: – moduleMap.js
  • 36. Copyright © 2016 M/Gateway Developments Ltd Create moduleMap.js module.exports = { testapp: '/opt/qewd/mapped/testapp' } Save as ~/qewd/modules/moduleMap.js
  • 37. Copyright © 2016 M/Gateway Developments Ltd Create moduleMap.js module.exports = { testapp: '/opt/qewd/mapped/testapp' } The module map exports as many mappings as you want Save as ~/qewd/modules/moduleMap.js
  • 38. Copyright © 2016 M/Gateway Developments Ltd Create moduleMap.js module.exports = { testapp: '/opt/qewd/mapped/testapp' } The module map exports as many mappings as you want We just need this one. Save as ~/qewd/modules/moduleMap.js
  • 39. Copyright © 2016 M/Gateway Developments Ltd Create moduleMap.js module.exports = { testapp: '/opt/qewd/mapped/testapp' } Note: the mapped module path is to the internal path within the container Save as ~/qewd/modules/moduleMap.js
  • 40. Copyright © 2016 M/Gateway Developments Ltd Create moduleMap.js module.exports = { testapp: '/opt/qewd/mapped/testapp' } Note: the mapped module path is to the internal path within the container, not the path we created on the host ~/qewd/modules/testapp.js
  • 41. Copyright © 2016 M/Gateway Developments Ltd That should be all we need • When we start the QEWD Appliance again, we must also map the directory containing the browser-side files, ie – ~/qewd/www/testapp
  • 42. Copyright © 2016 M/Gateway Developments Ltd Start the QEWD Appliance • On Linux: sudo docker run -d -p 8080:8080 --link redis:redis ↩ -v /home/ubuntu/qewd/modules:/opt/qewd/mapped ↩ -v /home/ubuntu/qewd/www/testapp:/opt/qewd/www/testapp ↩ rtweed/qewd
  • 43. Copyright © 2016 M/Gateway Developments Ltd Start the QEWD Appliance • On Raspberry Pi: sudo docker run -d -p 8080:8080 --link redis:redis ↩ -v /home/pi/qewd/modules:/opt/qewd/mapped ↩ -v /home/pi/qewd/www/testapp:/opt/qewd/www/testapp ↩ rtweed/rpi-qewd
  • 44. Copyright © 2016 M/Gateway Developments Ltd Try running testapp It works The console show that testapp correctly registered itself on QEWD Try clicking the button..
  • 45. Copyright © 2016 M/Gateway Developments Ltd Try running testapp It works too! A message was sent to the QEWD back-end which returned the expected response
  • 46. Copyright © 2016 M/Gateway Developments Ltd Check the Session Start the qewd-monitor application and click the Session tab:
  • 47. Copyright © 2016 M/Gateway Developments Ltd Check the Session Start the qewd-monitor application and click the Session tab: Where did this come from?
  • 48. Copyright © 2016 M/Gateway Developments Ltd It came from testapp.js module.exports = { handlers: { testButton: function(messageObj, session, send, finished) { console.log('*** handling the button click message!'); session.data.$('foo').value = 'bar'; finished({ ok: 'testButton message was processed successfully!' }); } } }; Save as ~/qewd/modules/testapp.js
  • 49. Copyright © 2016 M/Gateway Developments Ltd QEWD Apps with no moving parts! • We just created a QEWD app without having anything installed other than Docker • We just defined: – the HTML and JavaScript files for the browser – The back-end JavaScript handler module • And mapped their directories as Docker volumes
  • 50. Copyright © 2016 M/Gateway Developments Ltd Adding more apps • Each app you create will need its own subdirectory under the ~/qewd/www directory – For its browser-side HTML, JavaScript, etc files – Each of these will have to be mapped to the corresponding volume in the QEWD container • Their back-end modules, however, just go into your mapped ~/qewd/modules folder – And then define their module mapping in moduleMap.js
  • 51. Copyright © 2016 M/Gateway Developments Ltd Mapping Multiple Apps module.exports = { testapp: '/opt/qewd/mapped/testapp', mySecondApp: '/opt/qewd/mapped/mySecondApp', myThirdApp: '/opt/qewd/mapped/myThirdApp' } ~/qewd/modules/moduleMap.js
  • 52. Copyright © 2016 M/Gateway Developments Ltd Mapping Multiple Apps • eg, On Linux: sudo docker run -d -p 8080:8080 --link redis:redis ↩ -v /home/ubuntu/qewd/modules:/opt/qewd/mapped ↩ -v /home/ubuntu/qewd/www/testapp:/opt/qewd/www/testapp ↩ -v /home/ubuntu/qewd/www/mySecondApp:/opt/qewd/www/mySecondApp ↩ -v /home/ubuntu/qewd/www/myThirdApp:/opt/qewd/www/myThirdApp ↩ rtweed/qewd
  • 53. Copyright © 2016 M/Gateway Developments Ltd What about REST APIs? • We can use the QEWD Docker Appliance to very quickly create REST APIs, again without any moving parts other than Docker itself • Even simpler to create than applications
  • 54. Copyright © 2016 M/Gateway Developments Ltd Let's create an API • We'll define a URL path prefix: – /api • And handle any lower-level URLs, eg: – /api/test • To do this we just need to create a handler module for the /api path. We'll call it api.js. It must be saved into the ~/qewd/modules directory
  • 55. Copyright © 2016 M/Gateway Developments Ltd Create api.js module.exports = { restModule: true, handlers: { test: function(messageObj, finished) { finished({foo: 'bar'}); } } }; Save as ~/qewd/modules/api.js
  • 56. Copyright © 2016 M/Gateway Developments Ltd Create api.js module.exports = { restModule: true, handlers: { test: function(messageObj, finished) { finished({foo: 'bar'}); } } }; Save as ~/qewd/modules/api.js It's just a standard QEWD REST/Web Service Module
  • 57. Copyright © 2016 M/Gateway Developments Ltd Create api.js module.exports = { restModule: true, handlers: { test: function(messageObj, finished) { finished({foo: 'bar'}); } } }; This function, test, will handle any incoming /api/test requests
  • 58. Copyright © 2016 M/Gateway Developments Ltd QEWD needs to know how to find it • As we're defining the handler module in a mapped directory, we need to tell QEWD where to find it and how to define it as a route. • For this we define a reserved named file in our ~/qewd/modules directory: – routes.js
  • 59. Copyright © 2016 M/Gateway Developments Ltd Create routes.js module.exports = [ { path: '/api', module: '/opt/qewd/mapped/api' } ]; Save as ~/qewd/modules/routes.js
  • 60. Copyright © 2016 M/Gateway Developments Ltd Create routes.js module.exports = [ { path: '/api', module: '/opt/qewd/mapped/api' } ]; Save as ~/qewd/modules/routes.js You export an array of route objects We'll just define one for /api in this example, but you can define as many routes as you wish
  • 61. Copyright © 2016 M/Gateway Developments Ltd Create routes.js module.exports = [ { path: '/api', module: '/opt/qewd/mapped/api' } ]; Note that the route must map to the container's internal mapped volume path So any incoming requests with a URL starting /api will be handled by the api.js file we've created in the host's mapped directory
  • 62. Copyright © 2016 M/Gateway Developments Ltd Let's try it • Our handler function isn't making any distinctions about the HTTP method used, so we can test it just using a browser.
  • 63. Copyright © 2016 M/Gateway Developments Ltd Let's try it It worked!
  • 64. Copyright © 2016 M/Gateway Developments Ltd REST/Web Service APIs • Of course this was a very simple example • But you can write as complex APIs as you wish. • All the functionality described in parts 31 and 36 of this course are available in the QEWD Docker Appliance
  • 65. Copyright © 2016 M/Gateway Developments Ltd REST APIs without moving parts • You can now define Web/REST APIs by writing JavaScript handler module files • No need to install Node.js
  • 66. Copyright © 2016 M/Gateway Developments Ltd Customising QEWD Appliance • QEWD Docker Appliance defaults: – Management password: keepThisSecret! • Always a good idea to change this! – Server name: QEWD Docker Server • Used by the qewd-monitor application – Worker pool size: 1 • You can change these
  • 67. Copyright © 2016 M/Gateway Developments Ltd Customising QEWD Appliance • Create a file named custom.js in your mapped directory (eg ~/qewd/mapped) – custom.js is a reserved name that the QEWD Docker Appliance will look for and use for customising its configuration
  • 68. Copyright © 2016 M/Gateway Developments Ltd Create custom.js module.exports = { config: { managementPassword: 'mySecret!', serverName: 'Robs QEWD Docker Appliance', poolSize: 2 } }; Save as ~/qewd/modules/custom.js
  • 69. Copyright © 2016 M/Gateway Developments Ltd Restart the Appliance • eg: – sudo docker restart d81 • Try running qewd-monitor – You'll need to use your new custom login password – It will display the new name for your server – It will show 2 worker processes
  • 70. Copyright © 2016 M/Gateway Developments Ltd Further Customisation • You can get access to the master process objects: – Create user defined data / objects that are passed to worker processes – Access the ewd-qoper8 object – Access the Express object • Define a run function. This is invoked when QEWD starts.
  • 71. Copyright © 2016 M/Gateway Developments Ltd Create custom.js function customise(config, q, intercept) { console.log('*** This is the custom function calling!'); } module.exports = { config: { run: customise, managementPassword: 'mySecret!', serverName: 'Robs QEWD Docker Appliance', poolSize: 2 } }; Save as ~/qewd/modules/custom.js
  • 72. Copyright © 2016 M/Gateway Developments Ltd Create custom.js function customise(config, q, intercept) { console.log('*** This is the custom function calling!'); } module.exports = { config: { run: customise, managementPassword: 'mySecret!', serverName: 'Robs QEWD Docker Appliance', poolSize: 2 } }; q is the main ewd-qoper8 object intercept.app is the Express object allowing you to add custom middleware
  • 73. Copyright © 2016 M/Gateway Developments Ltd That's the QEWD Docker Appliance • A handy and simple, low-impact way of using QEWD without worrying about interactions with your existing set-up – And without having to install Node.js or a database • All the functionality of a standard local implementation of QEWD is still available to you