Skip to content

Commit bb39560

Browse files
author
Simon Tennant
committed
Merge pull request buddycloud#188 from buddycloud/docker
Add docker support. Merging with honour.
2 parents 1035e25 + 188ab39 commit bb39560

File tree

9 files changed

+70
-9
lines changed

9 files changed

+70
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
node_modules/
22
config.js
3+
!contrib/docker/config.js
34
.project
45
.settings
56
.DS_Store
67
public/scripts/buddycloud.js
8+
npm-debug.log

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ MAINTAINER Lloyd Watkin <lloyd@evilprofessor.co.uk>
99

1010
EXPOSE 9123
1111

12-
ENV NODE_ENV production
12+
ENV NODE_ENV $NODE_ENV
1313

1414
RUN apt-get update
1515
RUN apt-get upgrade -y
1616
RUN apt-get install -y git git-core libicu-dev libexpat-dev build-essential libssl-dev build-essential g++
1717

1818
RUN git clone https://github.com/buddycloud/buddycloud-http-api.git api-server
19-
RUN cd api-server && npm i .
20-
RUN cd api-server && cp contrib/docker/config.js .
21-
CMD cd api-server && npm start
19+
RUN cd api-server && git checkout docker
20+
RUN cd api-server && npm i . && cp contrib/docker/config.js .
21+
ADD contrib/docker/start.sh /data/
22+
23+
RUN chmod +x start.sh
24+
CMD ./start.sh

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,29 @@ which you can instantiate to give you a websocket connection.
2222

2323
Please see [buddycloud.com](http://www.buddycloud.com) for more information on using this connection.
2424

25+
## Docker
26+
27+
There is a docker image available for the API server. Configuration is currently passed via environment variables:
28+
29+
| Configuration | Example | Description | Required or default |
30+
|:----------------------: |:------------------------: |:---------------------------------------------------------------------------------------------------: |:-------------------: |
31+
| XMPP_DOMAIN | buddycloud.org | The XMPP domain for your server ||
32+
| XMPP_HOST | 192.168.0.55 | The hostname or IP of your XMPP server ||
33+
| CHANNEL_COMPONENT | channels.buddycloud.org | The channel server component address ||
34+
| ANONYMOUS_COMPONENT | anon.buddycloud.org | An 'anonymous' component which can be used for open nodes | null |
35+
| MEDIA_ENDPOINT | http://192.168.0.56:9000 | The endpoint for a [media server](https://github.com/buddycloud/buddycloud-media-server) | null |
36+
| PUSHER_COMPONENT | pusher.buddycloud.org | The location of a [pusher component](https://github.com/buddycloud/buddycloud-pusher) | null |
37+
| FRIENDFINDER_COMPONENT | finder.buddycloud.org | The location of a [friend finder component](https://github.com/buddycloud/buddycloud-friend-finder) | null |
38+
| SEARCH_COMPONENT | search.buddycloud.org | The location of a [search component](https://github.com/buddycloud/channel-directory) | null |
39+
| DISABLE_WEBSOCKET | 0 | Whether to disable the [XMPP-FTW](https://xmpp-ftw.jit.su) endpoint | false |
40+
| DEBUG | 1 | Whether to write additional debug to the logs | false |
41+
42+
Then simply launch the API server with the required environment variables as follows:
43+
44+
```bash
45+
docker run -d -p 9123:9123 -e ..... buddycloud/api-server
46+
```
47+
2548
## Issues
2649

2750
Please log any issues at https://github.com/buddycloud/buddycloud-http-api/issues

config.js.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
exports._ = {
2020
// This is the port that your webserver's reverse proxy will forward requests to
2121
port: 9123,
22+
23+
// Whether to disable the xmpp-ftw endpoint
24+
disableWebsocket: false
2225
};
2326

2427
// Production settings

contrib/docker/config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
exports._ = {
2+
// This is the port that your webserver's reverse proxy will forward requests to
3+
port: 9123,
4+
};
5+
6+
if (!process.env.XMPP_DOMAIN) {
7+
throw new Error('Missing XMPP domain')
8+
}
9+
if (!process.env.XMPP_HOST) {
10+
throw new Error('Missing XMPP host')
11+
}
12+
if (!process.env.CHANNEL_COMPONENT) {
13+
throw new Error('Missing channel server component')
14+
}
15+
16+
// Production settings
17+
exports.production = {
18+
debug: process.env.DEBUG || false,
19+
xmppDomain: process.env.XMPP_DOMAIN,
20+
xmppHost: process.env.XMPP_HOST,
21+
xmppAnonymousDomain: process.env.ANONYMOUS_COMPONENT,
22+
channelDomain: process.env.CHANNEL_COMPONENT,
23+
pusherComponent: process.env.PUSHER_COMPONENT,
24+
friendFinderComponent: process.env.FRIENDFINDER_COMPONENT,
25+
searchComponent: process.env.SEARCH_COMPONENT,
26+
homeMediaRoot: process.env.MEDIA_ENDPOINT,
27+
createUserOnSessionCreation: true,
28+
disableWebsocket: (typeof process.env.DISABLE_WEBSOCKET !== 'undefined') ? process.env.DISABLE_WEBSOCKET : false
29+
}

contrib/docker/start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd api-server
4+
npm start

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"ltx": "~0.3.0",
1919
"node-expat": "~2.0.0",
2020
"jwt-simple": "0.1.x",
21-
"iso8601": "1.1.1",
2221
"pubcontrol": "0.3.1",
2322
"grip": "0.1.4",
2423
"segfault-handler": "git+https://github.com/ddopson/node-segfault-handler.git",

src/content_feed.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// Handles requests related to channel node feeds
1919
// (/<channel>/content/<node>).
2020

21-
var iso8601 = require('iso8601');
2221
var ltx = require('ltx');
2322
var api = require('./util/api');
2423
var atom = require('./util/atom');
@@ -73,8 +72,8 @@ function getNodeFeedNext(req, res) {
7372
var prevId = null;
7473
if (req.query.since_post && req.query.since_time) {
7574
var since_post = req.query.since_post;
76-
var since_time = Math.floor(iso8601.toDate(req.query.since_time).getTime() / 1000) * 1000;
77-
logger.debug("since_post=" + since_post + "&since_time=" + iso8601.fromDate(new Date(since_time)) + " (" + since_time + ")");
75+
var since_time = Math.floor(Date.parse(req.query.since_time).getTime() / 1000) * 1000;
76+
logger.debug("since_post=" + since_post + "&since_time=" + new Date(since_time).toISOString() + " (" + since_time + ")");
7877
var start = null;
7978
if (sub.items !== undefined) {
8079
for (var i = sub.items.length - 1; i >= 0; --i) {

src/util/session.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
var Client = require('node-xmpp-client')
2121
, http = require('http')
22-
, iso8601 = require('iso8601')
2322
, jwt = require('jwt-simple')
2423
, api = require('./api')
2524
, cache = require('./cache')

0 commit comments

Comments
 (0)