Skip to content

Instantly share code, notes, and snippets.

View mdobson's full-sized avatar
😺
Petting a cat

Matthew Dobson mdobson

😺
Petting a cat
View GitHub Profile
@mdobson
mdobson / 1.js
Created December 3, 2013 14:24
pipe docker container events to stdout
var Docker = require('dockerode');
var dockerApiClient = new Docker({host: 'http://mdob.io', port:4243});
dockerApiClient.getEvents({since: ((new Date().getTime()/1000) - 60).toFixed(0)}, function(err, stream) {
if(err) {
console.log(err);
} else {
stream.pipe(process.stdout);
}
});
@mdobson
mdobson / deploy.sh
Last active December 29, 2015 15:49
Deploy script
#!/bin/bash
if [ $(git rev-parse --is-bare-repository) = true ]
then
appName=$(basename "$PWD")
else
appName=$(basename $(readlink -nf "$PWD"/..))
fi
echo "Preparing to deploy $appName"
tarPath="$HOME/tmp/$appName.tar"
ipaddr=$(ip addr show eth0 | grep inet | head -n1 | awk '{ print $2 }')
@mdobson
mdobson / gist:7686736
Created November 28, 2013 03:09
Commands to pull couchdb and launch in container.
docker pull shykes/couchdb
docker run -d -p 5984 shykes/couchdb
@mdobson
mdobson / 1.sh
Created November 25, 2013 01:44
hooks
export GIT_WORK_TREE=/root/apps/test
git checkout -f
/bin/bash /root/apps/test/scripts/restart.sh && exit 0
@mdobson
mdobson / gist:7632286
Created November 24, 2013 20:57
checking out the interface that container is bound to
docker -H tcp://$myip:4243/ inspect [CONTAINER ID] | grep IPAddress | cut -d '"' -f 4
@mdobson
mdobson / 1.sh
Created November 18, 2013 16:58
Pull ip address of current machine. (Will help with docker scripts)
addr=$(ip addr show eth0 | grep inet | head -n1 | awk '{ print $2 }')
echo ${addr/\/[0-9][0-9]/}
@mdobson
mdobson / gist:7509165
Last active December 28, 2015 13:39
Docker command to open port 8080 to native host interface
#Run docker with interactive tutorial
docker run -v /root/apps/test:/test -i -p 8080:8080 nodeapp /bin/bash -c "node /test/server.js"
#in /etc/init/docker.conf we update to activate remote API via tcp socket for access over HTTP
description "Docker daemon"
start on filesystem and started lxc-net
stop on runlevel [!2345]
@mdobson
mdobson / 1.sh
Created November 17, 2013 03:20
Dockerfile for node from scratch
# Nodejs
# Version 0.0.1
FROM ubuntu
MAINTAINER Matthew S. Dobson <[email protected]>
RUN echo "Updating packages."
#Updated repos to 13.10 so we can get a more up to date node from apt-get
RUN echo "deb http://archive.ubuntu.com/ubuntu saucy main universe" > /etc/apt/sources.list
RUN echo "Done..."
@mdobson
mdobson / get.js
Created November 11, 2013 20:17
Getting and connecting an entity to a user.
var apigee = new Apigee.Client({
orgName:"mdobson",
appName:"sandbox",
logging:true
});
//You'll need to use the login function to have access to this entity.
apigee.getLoggedInUser(function(error, data, user){
if(error) {
@mdobson
mdobson / restart.sh
Created November 10, 2013 15:33
Restart script
#!/bin/bash
PID=`pgrep -fl node`
APPDIR=/root/apps/test
if [ -n "$PID" ]
then
echo "Stopping servers : ${PID}"
echo "$PID" | awk '{ print $1 }' | xargs kill
sleep 2
fi
cd $APPDIR