Skip to content

Commit

Permalink
add Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
shprink committed Jun 7, 2015
1 parent f47a9d4 commit bf08cdb
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 46 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:0.10.38
MAINTAINER Julien Renaux <[email protected]>
RUN mkdir /wphc

ENV HOST 0.0.0.0
EXPOSE 8080

WORKDIR /wphc
ADD . /wphc

RUN \
npm install -g [email protected] # && \
45 changes: 43 additions & 2 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
## Installation
You have the choice to install WPHC directly on your machine (node, npm, bower are required) or you can install WPHC via bower with no other preriquisites than Docker itself.

NB: The following installation was made for OSX and Linux (Debian/Ubuntu). There is no Windows support.
## Local Installation

### Preriquisites

* NodeJS
* NPM
* Bower

### Clone repository

Expand All @@ -15,10 +16,50 @@ git clone [email protected]:shprink/wordpress-hybrid-client.git

### Run install.sh

The installation will not install anything globally to avoid potential version conflicts.

```
sh ./install.sh
```

## Docker Installation

### Preriquisites

* Docker

Install [Docker](https://www.docker.com/) on your system.

* [Install instructions](https://docs.docker.com/installation/mac/) for Mac OS X
* [Install instructions](https://docs.docker.com/installation/ubuntulinux/) for Ubuntu Linux
* [Install instructions](https://docs.docker.com/installation/) for other platforms

### Pull images

```
Docker pull shprink/wphc
```

### Run

```
docker run -it -v /local/path/to/wordpress-hybrid-client:/wphc shprink/wphc bash
```

Now you should be inside you docker, try listing folders to make sure they are accessible:

```
root@c5d7db4eaf05:/wphc$ ls -la
```

You should see the WPHC files listed. If not and using boot2docker please read this <https://gist.github.com/codeinthehole/7ea69f8a21c67cc07293>

You are now ready to install WPHC:

```
root@c5d7db4eaf05:/wphc$ sh ./install.sh
```

### Config files

Now that the installation is done two files
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
web:
build: .
ports:
- ":8080"
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -e

npm install -g cordova ionic webpack webpack-dev-server

npm install

bower install

# Dev App config
cp config.json.dist config.json
# Prod App config
Expand Down
10 changes: 3 additions & 7 deletions lib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
<script>
var wordpressHybridClient = {};
wordpressHybridClient.version = "{%= o.htmlWebpackPlugin.options.pkg.version %}";
wordpressHybridClient.js = {}
wordpressHybridClient.js.name = "{%= o.htmlWebpackPlugin.assets['main'].name %}";
wordpressHybridClient.js.size = "{%= o.htmlWebpackPlugin.assets['main'].size %}";
</script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
</head>
<body ng-strict-di ng-app="wordpress-hybrid-client">
<ion-nav-view></ion-nav-view>
{% for (var chunk in o.htmlWebpackPlugin.assets) { %}
<script src="{%=o.htmlWebpackPlugin.assets[chunk].name%}"></script>
{% for (var chunk in o.htmlWebpackPlugin.files) { %}
<script src="{%=o.htmlWebpackPlugin.files[chunk]%}"></script>
{% } %}
</body>
<!-- {%= o.htmlWebpackPlugin.options.pkg.name + ' v' + o.htmlWebpackPlugin.options.pkg.version + ' size: ' + o.htmlWebpackPlugin.assets['main'].size + ' built on ' + new Date() %} -->

<!-- {%= o.htmlWebpackPlugin.options.pkg.name + ' v' + o.htmlWebpackPlugin.options.pkg.version + ' built on ' + new Date() %} -->
</html>
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
"description": "AngularJS client using Ionic Framework and based on the json-rest-api plugin: https://wordpress.org/plugins/json-rest-api/ with CORS enabled.",
"main": "index.js",
"scripts": {
"install": "bower install",
"update": "bower update",
"build": "sh ./release.sh",
"devserver": "webpack-dev-server --port 9100 --progress",
"devserver": "webpack-dev-server --port 8080 --json --progress",
"dumpdev": "gulp build",
"dumpprod": "gulp build:prod"
},
Expand All @@ -33,10 +31,11 @@
},
"homepage": "https://github.com/shprink/wordpress-hybrid-client",
"devDependencies": {
"autoprefixer-loader": "^1.1.0",
"autoprefixer-loader": "^2.0.0",
"clone": "^0.2.0",
"coffee-loader": "^0.7.2",
"coffee-script": "^1.8.0",
"cordova": "^5.0.0",
"css-loader": "^0.9.1",
"exports-loader": "^0.6.2",
"expose-loader": "^0.6.0",
Expand All @@ -55,16 +54,18 @@
"gulp-xml-editor": "^2.2.1",
"html-loader": "^0.2.3",
"html-webpack-plugin": "^1.1.0",
"ionic": "^1.5.0",
"json-loader": "^0.5.1",
"markdown-loader": "^0.1.2",
"ng-annotate": "^0.15.2",
"ng-annotate-webpack-plugin": "^0.1.2",
"path": "^0.4.9",
"sass-loader": "^0.3.1",
"sass-loader": "^0.5.0",
"semver": "^4.3.4",
"style-loader": "^0.8.3",
"util": "^0.10.3",
"webpack": "^1.4.13",
"webpack": "^1.7.3",
"webpack-dev-server": "^1.6.6",
"xml2js": "^0.4.8"
},
"dependencies": {
Expand Down Expand Up @@ -108,4 +109,4 @@
"locator": "./engine/cordova-android-c0.6.1/"
}
]
}
}
29 changes: 1 addition & 28 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,6 @@ var path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ngAnnotatePlugin = require('ng-annotate-webpack-plugin');

HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function(compiler, webpackStatsJson) {
var assets = {};
for (var chunk in webpackStatsJson.assetsByChunkName) {
var chunkValue = webpackStatsJson.assetsByChunkName[chunk];

// Webpack outputs an array for each chunk when using sourcemaps
if (chunkValue instanceof Array) {
// Is the main bundle always the first element?
chunkValue = chunkValue[0];
}

if (compiler.options.output.publicPath) {
chunkValue = compiler.options.output.publicPath + chunkValue;
}
for (var i = 0; i < webpackStatsJson.assets.length; i++) {
var asset = webpackStatsJson.assets[i];
if (asset.name.indexOf('css/style') === 0) {
assets['css'] = asset;
}
if (asset.name === chunkValue) {
assets[chunk] = asset;
}
}
}
return assets;
};

module.exports = {
entry: path.join(libPath, 'index.coffee'),
output: {
Expand Down Expand Up @@ -105,4 +78,4 @@ module.exports = {
IS_PROD: false
})
]
};
};

0 comments on commit bf08cdb

Please sign in to comment.