Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Build 2.2.0: Added resources for using QEWD Docker Container with Con…
Browse files Browse the repository at this point in the history
…duit
  • Loading branch information
robtweed committed Sep 3, 2017
1 parent 9cf1f08 commit a830b58
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "qewd-conduit",
"version": "2.1.1",
"version": "2.2.0",
"description": "QEWD-based Conduit RESTFUL Back-end",
"main": "index.js",
"scripts": {
Expand Down
49 changes: 49 additions & 0 deletions qewd-docker/README.md
@@ -0,0 +1,49 @@
# Using the Docker Version of QEWD with QEWD-Conduit

- Install Docker
- On your host server, create a directory for the docker-specific control files, eg ~/qewd-docker-files

## If you want to use the React/Redux version of the RealWorld Conduit front-end

- copy custom-React-REST.js to the directory you created, and rename it to custom,js, eg

~/qewd-docker-files/custom.js

## If you want to use the pre-built WebSocket version of the RealWorld Conduit front-end that comes with QEWD-conduit

- copy custom-websocket-UI.js to the directory you created, and rename it to custom,js, eg

~/qewd-docker-files/custom.js


## Copy routes.js to the same directory, eg:

~/qewd-docker-files/routes.js



## Start the Docker version of QEWD:

replace {username} with the home username for your server

sudo docker run -it -p 8080:8080 --link redis:redis -v /home/{username}/qewd-docker-files:/opt/qewd/mapped rtweed/qewd

If you want to run silently as a daemon, replace the -it option with -d


If you're using a Raspberry Pi, use this instead:

sudo docker run -it -p 8080:8080 --link redis:redis -v /home/{username}/qewd-docker-files:/opt/qewd/mapped rtweed/rpi-qewd

If you want to run silently as a daemon, replace the -it option with -d


## Start the UI in a browser

http://{ip-address}:8080/index.html

You're now running the RealWorld Conduit front-end against a dockerised version of QEWD.js




35 changes: 35 additions & 0 deletions qewd-docker/custom-React-REST.js
@@ -0,0 +1,35 @@
// Set up an instance of the REST-based RealWorld Conduit application

var serverAddress = '192.168.1.122:8080';

function customise(config, q, intercept) {
var cp = require('child_process');

// install the qewd-conduit back-end

cp.execSync('npm install qewd-conduit',{stdio:[0,1,2]});

// download a pre-built copy of React/Redux version of REST-based Conduit UI

cp.execSync('wget https://s3.amazonaws.com/mgateway/conduit/conduit.zip',{stdio:[0,1,2]});

// install Node.js module for unzipping files

cp.execSync('npm install extract-zip',{stdio:[0,1,2]});
var unzip = require('extract-zip');

// Unzip the UI, copying the extracted files to the QEWD Web Server root path

unzip('/opt/qewd/conduit.zip', { dir: '/opt/qewd/www' }, function (err) {

// Once it's all unzipped, modify the UI's bundled JS file so it points REST requests at our QEWD Container

cp.execSync('sed -i s/192.168.1.122:8080/' + serverAddress + '/g /opt/qewd/www/static/js/main.d4022d9e.js',{stdio:[0,1,2]});
console.log('*** Ready for use ***');
})

}

module.exports = {
run: customise
};
24 changes: 24 additions & 0 deletions qewd-docker/custom-websocket-UI.js
@@ -0,0 +1,24 @@
// Using the WebSockets version of the Conduit UI

var serverAddress = '192.168.1.122:8080';

function customise(config, q, intercept) {
var cp = require('child_process');

// install qewd-conduit back-end module

cp.execSync('npm install qewd-conduit',{stdio:[0,1,2]});

// copy the UI from the repo that we've just installed into the QEWD Web Server root path

cp.execSync('cp -R /opt/qewd/node_modules/qewd-conduit/www/* /opt/qewd/www',{stdio:[0,1,2]});

// change the UI logic's IP address to that of this server

cp.execSync('sed -i s/178.62.26.29:8080/' + serverAddress + '/g /opt/qewd/www/bundle.js',{stdio:[0,1,2]});
console.log('*** Ready for use ***');
}

module.exports = {
run: customise
};
6 changes: 6 additions & 0 deletions qewd-docker/routes.js
@@ -0,0 +1,6 @@
module.exports = [
{
path: '/api',
module: 'qewd-conduit'
}
];

0 comments on commit a830b58

Please sign in to comment.