Skip to content
Permalink
Browse files

Docker Image

  • Loading branch information...
harshadyeola committed Feb 9, 2016
1 parent 0f0f765 commit 481dc52c979e6be2f443e34b16458608c08166f3
Showing with 110 additions and 0 deletions.
  1. +31 −0 Dockerfile
  2. +79 −0 media-node.sh
@@ -0,0 +1,31 @@
FROM ubuntu:14.04

MAINTAINER Harshad Yeola harshadyeola92@gmail.com

EXPOSE 1203

# Keep upstart from complaining
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -sf /bin/true /sbin/initctl

# Let the conatiner know that there is no tty
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update

RUN apt-get install -y wget curl

ADD ./ubuntu.sh /ubuntu.sh
RUN /bin/bash /ubuntu.sh

VOLUME /root/media-node/queued /root/media-node/temp /root/media-node/completed /root/media-node/log

WORKDIR /root/media-node

RUN npm install -g

RUN npm install formidable connect sqlite3

RUN touch /root/media-node/log/ffmpeg_server.log

ENTRYPOINT ["/usr/local/bin/node", "ffmpeg_server.js"]
@@ -0,0 +1,79 @@
#!/bin/bash

command=$1

usage () {
echo "Usage: launcher COMMAND CONFIG [--skip-prereqs]"
echo "Commands:"
echo " start: Start/initialize a container"
echo " stop: Stop a running container"
echo " restart: Restart a container"
echo " logs: Docker logs for container"
exit 1
}

set_existing_container(){
existing=`docker ps -a | awk '{ print $1, $(NF) }' | grep " media-node" | awk '{ print $1 }'`
}

run_stop () {
set_existing_container
if [ ! -z $existing ]
then
(
set -x
docker stop -t 10 media-node
)
else
echo "media-node was not started !"
exit 1
fi
}

run_start () {
mkdir -p /root/media-node/{temp,completed,queued}
existing=`docker ps | awk '{ print $1, $(NF) }' | grep " media-node" | awk '{ print $1 }'`
echo $existing
if [ ! -z $existing ]
then
echo "Nothing to do, your container has already started!"
exit 1
# else
# docker run -id --name media-node --restart=always -p 1203:1203 -v /root/media-node/completed:/root/completed -v /root/media-node/temp:/root/temp -v /root/media-node/queued:/root/queued rtcamp/media-node
fi
existing=`docker ps -a | awk '{ print $1, $(NF) }' | grep " media-node" | awk '{ print $1 }'`
if [ ! -z $existing ]
then
echo "starting up existing container"
(
set -x
docker start media-node
)
exit 0
fi
docker run -id --name media-node --restart=always -p 1203:1203 -v /root/media-node/completed:/root/media-node/completed -v /root/media-node/temp:/root/media-node/temp -v /root/media-node/queued:/root/media-node/queued rtcamp/media-node
}

case "$command" in
stop)
run_stop
exit 0
;;

logs)
docker logs media-node
exit 0
;;

restart)
run_stop
run_start
exit 0
;;

start)
run_start
exit 0
;;
esac
usage

0 comments on commit 481dc52

Please sign in to comment.
You can’t perform that action at this time.