Skip to content

Commit

Permalink
Moving to Docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Labuschagne committed Apr 30, 2016
1 parent 433680b commit 869e0bb
Show file tree
Hide file tree
Showing 26 changed files with 81 additions and 214 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
.*.swp
*.log
*.tbz2
node_modules
ontario
build
45 changes: 16 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
include *.mk
DOCKER=docker
COMPOSE=docker-compose
IMAGES=downlink/reveal-sync-app downlink/reveal-sync-static

.PHONY: all deploy-staging remove-staging deploy-prod remove-prod install run clean
.PHONY: all images dist run clean

all: $(GROUP_VARS) $(PACKAGE)
@echo $(PACKAGE)
all: images dist

deploy-staging: $(GROUP_VARS) $(PACKAGE)
cd ansible; ansible-playbook -i ./staging -K ./deploy.yml
images:
$(COMPOSE) build static app

remove-staging: $(GROUP_VARS)
cd ansible; ansible-playbook -i ./staging -K ./remove.yml
dist:
for i in $(IMAGES); do $(DOCKER) save -o $$(basename $$i).tar $$i; done
tar -jcvf reveal-sync_$$(date +%Y-%m-%d).tbz2 reveal-sync*.tar
rm -v reveal-sync*.tar
@echo "*** Now copy reveal-sync*.tar.gz to your server."

deploy-prod: $(GROUP_VARS) $(PACKAGE)
cd ansible; ansible-playbook -i ./production -K ./deploy.yml

remove-prod: $(GROUP_VARS)
cd ansible; ansible-playbook -i ./production -K ./remove.yml

$(GROUP_VARS): $(GROUP_VARS).pgp package.json
gpg -o $@ -d $<
@grep appname $(GROUP_VARS) || echo "appname: "$(NAME) >> $(GROUP_VARS)
@grep version $(GROUP_VARS) || echo "version: "$(VERSION) >> $(GROUP_VARS)
@grep extractdir $(GROUP_VARS) || echo "extractdir: /opt/"$(NAME)-$(VERSION) >> $(GROUP_VARS)
@grep installdir $(GROUP_VARS) || echo "installdir: /opt/"$(NAME) >> $(GROUP_VARS)

$(PACKAGE): package.json $(NODE_SOURCES)
npm install
test -f bower.json && ./node_modules/.bin/bower install || :
mkdir -p build
rsync -avz --include-from build-include . build/
mkdir -p $$(dirname $@)
cd build && tar -jcvf ../$@ *
run:
$(COMPOSE) up -d
$(COMPOSE) logs

clean:
rm -fr node_modules build $(PACKAGE) $(GROUP_VARS)
$(DOCKER) rmi $$($(DOCKER) images --filter dangling=true -q) $(IMAGES) || :

7 changes: 0 additions & 7 deletions ansible/deploy.yml

This file was deleted.

15 changes: 0 additions & 15 deletions ansible/group_vars/ontario.pgp

This file was deleted.

2 changes: 0 additions & 2 deletions ansible/production

This file was deleted.

7 changes: 0 additions & 7 deletions ansible/remove.yml

This file was deleted.

3 changes: 0 additions & 3 deletions ansible/roles/clean/handlers/main.yml

This file was deleted.

20 changes: 0 additions & 20 deletions ansible/roles/clean/tasks/main.yml

This file was deleted.

3 changes: 0 additions & 3 deletions ansible/roles/reveal_sync/handlers/main.yml

This file was deleted.

37 changes: 0 additions & 37 deletions ansible/roles/reveal_sync/tasks/main.yml

This file was deleted.

13 changes: 0 additions & 13 deletions ansible/roles/reveal_sync/templates/logrotate.j2

This file was deleted.

4 changes: 0 additions & 4 deletions ansible/roles/reveal_sync/templates/rsyslog.j2

This file was deleted.

2 changes: 0 additions & 2 deletions ansible/staging

This file was deleted.

16 changes: 0 additions & 16 deletions build-include

This file was deleted.

7 changes: 4 additions & 3 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"daemon": true,
"daemon": false,
"cluster": false,
"port": 9000,
"workers": 1,
"pid_dir": "/tmp",
"log": {
"facility": "local4",
"level": "info"
"facility": "stdout",
"level": "debug"
}
}
1 change: 0 additions & 1 deletion dist/socket.io.js

This file was deleted.

4 changes: 4 additions & 0 deletions dist/socket.io.min.1-4-5.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "2"
services:
lb:
image: dockercloud/haproxy:1.2.1
links:
- static
- app
ports:
- "8010:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
static:
image: downlink/reveal-sync-static
restart: always
build:
context: .
dockerfile: dockerfile-static
expose:
- "80"
environment:
VIRTUAL_HOST: "downlink.nz"
app:
image: downlink/reveal-sync-app
restart: always
build:
context: .
dockerfile: dockerfile-node
expose:
- "9000"
environment:
VIRTUAL_HOST: "sync.downlink.nz"
12 changes: 12 additions & 0 deletions dockerfile-node
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:4.3.0

COPY index.js LICENSE package.json /opt/reveal-sync/
COPY config/ /opt/reveal-sync/config/
COPY lib/ /opt/reveal-sync/lib/

RUN cd /opt/reveal-sync && npm install

WORKDIR /opt/reveal-sync

CMD ["node", "./index.js"]

6 changes: 6 additions & 0 deletions dockerfile-static
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:alpine

COPY dist/reveal-sync.js /usr/share/nginx/html/js/
COPY dist/socket.io.min.1-4-5.js /usr/share/nginx/html/js/socket.io.js

CMD ["nginx", "-g", "daemon off;"]
5 changes: 0 additions & 5 deletions global.mk

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (config.get('daemon')){
var cluster = require('cluster'),
log = require('./lib/logging');

if (cluster.isMaster){
if (config.get('cluster') && cluster.isMaster){
require('./lib/pidfile').write();

function spawn_child(){
Expand Down
2 changes: 1 addition & 1 deletion lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// }
// }

var syslog = require('node-syslog'),
var syslog = require('modern-syslog');
util = require('util'),
pkg = require('../package.json'),
uuid = require('./uuid'),
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reveal-sync",
"version": "1.0.0",
"version": "1.1.0",
"description": "Synchronized distributed Reveal.js presentations",
"main": "index.js",
"scripts": {
Expand All @@ -21,10 +21,10 @@
},
"homepage": "https://github.com/jlabusch/reveal-sync",
"dependencies": {
"config": "^1.12.0",
"daemon": "^1.1.0",
"node-syslog": "^1.1.7",
"node-uuid": "^1.4.3",
"socket.io": "^1.3.5"
"config": "~1.20",
"daemon": "~1.1",
"modern-syslog": "~1.1",
"node-uuid": "~1.4",
"socket.io": "1.4.5"
}
}
27 changes: 0 additions & 27 deletions start.sh

This file was deleted.

8 changes: 0 additions & 8 deletions stop.sh

This file was deleted.

0 comments on commit 869e0bb

Please sign in to comment.