kerberos-io / machinery

(DEPRECATED) An open source image processing framework, which uses your USB-, IP- or RPi-camera to recognize events (e.g. motion).
https://www.kerberos.io
490 stars 104 forks source link

Docker-ize Kerberos-io #13

Closed JasonSwindle closed 8 years ago

JasonSwindle commented 8 years ago

Howdy,

I can currently working on seeing if I can docker-ize this product. I think huge improvements could be made by shipping the different aspects in containers that link to each other. My step are to get a good build work-flow, which is semi-done. I was able to get a kerberos binary built on my Debian box. What do you think?

cedricve commented 8 years ago

Hello Jason

Nice. It would be very helpful indeed, I didn't had the time to work on docker. Will you dockerize both machinery and webinterface?

Thanks for your support, we can really use this.

JasonSwindle commented 8 years ago

Task List

JasonSwindle commented 8 years ago

My other idea would be that this product should be like how OpenELEC is setup with buildroot. Buildroot + systemD + Docker would make this a very powerful out of the box system.

cedricve commented 8 years ago

This sounds robust, and think this would be a huge step forward. Can we open a conversation on gitter?

JasonSwindle commented 8 years ago

Sure, currently at work, so I may not be able to jump in today. I am also not sure how much I can take on for this project but I can point out what I know. :)

cedricve commented 8 years ago

No problem, no commitments :)

cedricve commented 8 years ago

Hello Jason

The kerberosio binary is now completely static compiled (develop branch), do you have any instructions to build the docker workflow?

Regards

JasonSwindle commented 8 years ago

Howdy,

I will get started on that, and share it today or tomorrow. I had to give up on my workflow, and things in docker have changed a bit.

Thanks, Jason

On Tue, Nov 3, 2015 at 4:50 AM Cédric Verstraeten notifications@github.com wrote:

Hello Jason

The kerberosio binary is now completely static compiled (develop branch), do you have any instructions to build the docker workflow?

Regards

— Reply to this email directly or view it on GitHub https://github.com/kerberos-io/machinery/issues/13#issuecomment-153341975 .

JasonSwindle commented 8 years ago

I see that http://googlemock.googlecode.com/svn/trunk has moved to https://github.com/google/googlemock

cedricve commented 8 years ago

Thanks for the notice, are there any problems with the old repo?

JasonSwindle commented 8 years ago

I am geting an error that the repo is not found, and google code is going away soon-ish.... so it maybe time to update your links. :)

On Mon, Nov 9, 2015 at 7:13 AM Cédric Verstraeten notifications@github.com wrote:

Thanks for the notice, are there any problems with the old repo?

Reply to this email directly or view it on GitHub https://github.com/kerberos-io/machinery/issues/13#issuecomment-155091877 .

cedricve commented 8 years ago

Ok thanks Jason, I've update the repo url.

cedricve commented 8 years ago

@JasonSwindle , I've been busy with Docker lately, and I've managed to get a first version of the Dockerfile. It installs both web and machinery repositories. Both services are managed by supervisor.

This is how it looks like for the moment. The next step is to get it working so that a USB camera / Raspberry Pi camera is forwarded to the container.

FROM phusion/baseimage:0.9.15

MAINTAINER "Cédric Verstraeten" <hello@cedric.ws>

#################################
# Surpress Upstart errors/warning

RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -sf /bin/true /sbin/initctl

#############################################
# Let the container know that there is no tty

ENV DEBIAN_FRONTEND noninteractive

#########################################
# Update base image
# Add sources for latest nginx and cmake
# Install software requirements

RUN sudo sed -i -e 's/us.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list
RUN apt-get update && \
apt-get install -y software-properties-common && \
nginx=stable && \
add-apt-repository ppa:nginx/$nginx && \
apt-get update && \
apt-get upgrade -y
RUN apt-get -y install supervisor curl subversion libcurl4-gnutls-dev cmake dh-autoreconf nginx nodejs npm php5-fpm git php5-mysql php-apc php5-curl php5-gd php5-mcrypt php5-memcache php5-tidy php5-xsl pwgen 

########################################
# fix ownership of sock file for php-fpm

RUN sed -i -e "s/;listen.mode = 0660/listen.mode = 0750/g" /etc/php5/fpm/pool.d/www.conf && \
find /etc/php5/cli/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;

###################
# nginx site conf

RUN rm -Rf /etc/nginx/conf.d/* && \
rm -Rf /etc/nginx/sites-available/default && \
mkdir -p /etc/nginx/ssl
ADD ./web.conf /etc/nginx/sites-available/default.conf
RUN ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf

#####################
# Clone and build web

RUN git clone https://github.com/kerberos-io/web /var/www/web && \
cd /var/www/web && git checkout develop && \
chown -Rf www-data.www-data /var/www/web && \
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer && \
cd /var/www/web && \
php5enmod mcrypt && \
composer install --prefer-source && \
npm install -g bower && \
cd public && \
nodejs /usr/local/bin/bower --allow-root install

############################
# Clone and build machinery

RUN git clone https://github.com/kerberos-io/machinery /tmp/machinery && \
    cd /tmp/machinery && git checkout develop && \
    mkdir build && cd build && \
    cmake .. && make && make check && make install
RUN chown -Rf www-data.www-data /etc/kerberosio
RUN chmod -Rf 777 /etc/kerberosio/config
RUN rm -rf /tmp/machinery

#########################################
# Make capture directory visible and link

RUN rm /var/www/web/public/capture && \
ln -s /srv/capture/ /var/www/web/public/capture

VOLUME ["/srv/capture"]

##############
# Expose Ports

EXPOSE 443
EXPOSE 80

#############################
# Supervisor Config and start

ADD ./supervisord.conf /etc/supervisord.conf
ADD ./run.sh /run.sh
RUN chmod 755 /run.sh

CMD ["/bin/bash", "/run.sh"]

I've read a lot of articles which say it's hard to do so. Especially when running docker on (OSX/Windows); you'll need to enable USB filtering on the VM. Do you have some experience with this?

cedricve commented 8 years ago

docker is added to the different repositories, and a general docker project is created which contains a docker-compose file.