Merge branch 'patch-docker' of https://github.com/hamiltont/ZoneMinder into hamiltont-patch-docker
Conflicts: Dockerfile
This commit is contained in:
commit
12412ff5ca
21
Dockerfile
21
Dockerfile
|
@ -11,16 +11,13 @@ RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
|
||||||
# Install the prerequisites
|
# Install the prerequisites
|
||||||
RUN apt-get install -y build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg-turbo8-dev libjpeg-turbo8 libtheora-dev libvorbis-dev libvpx-dev libx264-dev libmp4v2-dev ffmpeg git wget mysql-client apache2 php5 php5-mysql apache2-mpm-prefork libapache2-mod-php5 php5-cli openssh-server mysql-server libvlc-dev libvlc5 libvlccore-dev libvlccore5 vlc-data vlc libcurl4-openssl-dev
|
RUN apt-get install -y build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm automake autoconf libjpeg-turbo8-dev libjpeg-turbo8 libtheora-dev libvorbis-dev libvpx-dev libx264-dev libmp4v2-dev ffmpeg mysql-client apache2 php5 php5-mysql apache2-mpm-prefork libapache2-mod-php5 php5-cli openssh-server mysql-server libvlc-dev libvlc5 libvlccore-dev libvlccore5 vlc-data vlc libcurl4-openssl-dev
|
||||||
|
|
||||||
# Grab the latest ZoneMinder code in master
|
# Copy local code into our container
|
||||||
RUN git clone https://github.com/kylejohnson/ZoneMinder.git
|
ADD . /ZoneMinder
|
||||||
|
|
||||||
# Change into the ZoneMinder directory
|
# Change into the ZoneMinder directory
|
||||||
WORKDIR ZoneMinder
|
WORKDIR /ZoneMinder
|
||||||
|
|
||||||
# Check out the release-1.27 branch
|
|
||||||
RUN git checkout release-1.27
|
|
||||||
|
|
||||||
# Setup the ZoneMinder build environment
|
# Setup the ZoneMinder build environment
|
||||||
RUN aclocal && autoheader && automake --force-missing --add-missing && autoconf
|
RUN aclocal && autoheader && automake --force-missing --add-missing && autoconf
|
||||||
|
@ -37,9 +34,16 @@ RUN make install
|
||||||
# Adding the start script
|
# Adding the start script
|
||||||
ADD utils/docker/start.sh /tmp/start.sh
|
ADD utils/docker/start.sh /tmp/start.sh
|
||||||
|
|
||||||
# Make start script executable
|
# Ensure we can run this
|
||||||
|
# TODO - Files ADD'ed have 755 already...why do we need this?
|
||||||
RUN chmod 755 /tmp/start.sh
|
RUN chmod 755 /tmp/start.sh
|
||||||
|
|
||||||
|
# Creating SSH privledge escalation dir
|
||||||
|
RUN mkdir /var/run/sshd
|
||||||
|
|
||||||
|
# Adding apache virtual hosts file
|
||||||
|
ADD utils/docker/apache-vhost /etc/apache2/sites-enabled/000-default
|
||||||
|
|
||||||
# Set the root passwd
|
# Set the root passwd
|
||||||
RUN echo 'root:root' | chpasswd
|
RUN echo 'root:root' | chpasswd
|
||||||
|
|
||||||
|
@ -47,5 +51,4 @@ RUN echo 'root:root' | chpasswd
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 22
|
EXPOSE 22
|
||||||
|
|
||||||
|
|
||||||
CMD "/tmp/start.sh"
|
CMD "/tmp/start.sh"
|
||||||
|
|
|
@ -128,6 +128,12 @@ perl-IO-Zlib perl-MailTools perl-MIME-Lite perl-MIME-tools perl-MIME-Types perl-
|
||||||
perl-TimeDate perl-YAML-Syck php php-cli php-mysql x264 vlc-devel vlc-core libcurl libcurl-devel
|
perl-TimeDate perl-YAML-Syck php php-cli php-mysql x264 vlc-devel vlc-core libcurl libcurl-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Docker
|
||||||
|
|
||||||
|
Docker is a system to run applications inside isolated containers. ZoneMinder, and the ZM webserver, will run using the
|
||||||
|
Dockerfile contained in this repository. However, there is still work needed to ensure that the main ZM features work
|
||||||
|
properly and are documented.
|
||||||
|
|
||||||
### ffmpeg
|
### ffmpeg
|
||||||
|
|
||||||
This release of ZoneMinder has been tested on and works with ffmpeg version N-55540-g93f4277.
|
This release of ZoneMinder has been tested on and works with ffmpeg version N-55540-g93f4277.
|
||||||
|
|
|
@ -1,21 +1,47 @@
|
||||||
# Overview
|
# Overview
|
||||||
|
|
||||||
Docker allows you to quickly spin up containers. The ZoneMinder dockerfile will spin
|
[Docker](https://www.docker.io/) allows you to quickly spin up application containers,
|
||||||
up an Ubuntu 12.04 container with mysql, apache, php and then compile and install ZoneMinder (from master).
|
which are similar to very lightweight virtual machines. The ZoneMinder Dockerfile will
|
||||||
|
start an Ubuntu 12.04 container with MySql, Apache, and PHP properly configured, and
|
||||||
|
will then compile and install ZoneMinder.
|
||||||
|
|
||||||
Afterwards you can connect to this container over SSH to check out the latest code.
|
It will also start an SSH server that you can use to log into the container.
|
||||||
|
|
||||||
This is still a bit of a work in progress.
|
This is still a bit of a work in progress.
|
||||||
|
|
||||||
## How To Use
|
## How To Use
|
||||||
|
|
||||||
1. Pull it
|
1. Install [Docker](https://www.docker.io/)
|
||||||
```sudo docker pull ubuntu:precise```
|
2. Build ZoneMinder container
|
||||||
2. Built it
|
|
||||||
```sudo docker build -t yourname/zoneminder github.com/ZoneMinder/ZoneMinder```
|
```sudo docker build -t yourname/zoneminder github.com/ZoneMinder/ZoneMinder```
|
||||||
3. Run it
|
3. Run it
|
||||||
```CID=$(sudo docker run -d -p 222:22 -p 8080:80 -name zoneminder yourname/zoneminder)```
|
```CID=$(sudo docker run -d -p 222:22 -p 8080:80 -name zoneminder yourname/zoneminder)```
|
||||||
4. Use it -- you can now SSH to port 222 on your host as user root with password root.
|
4. Use it -- you can now SSH to port 222 on your host as user root with password root.
|
||||||
You can also browse to your host on port 8080 to access the zoneminder web interface
|
You can also browse to your host on port 8080 to access the zoneminder web interface
|
||||||
|
|
||||||
|
## Developing With Docker
|
||||||
|
|
||||||
|
If you wish to contribute to ZoneMinder, Docker can be helpful. By re-running
|
||||||
|
```docker build``` in your working directory, any code modifications you have
|
||||||
|
made will be pulled into a new container, compiled, and started, all without
|
||||||
|
modifying your base system.
|
||||||
|
|
||||||
|
Development is not totally without annoyances, as any change
|
||||||
|
to the project will require a full rebuild of all C++. Docker notices that the
|
||||||
|
directory which has been ADD'ed is now different, and therefore all steps after
|
||||||
|
the ADD command must be recomputed. A fix for this is to update the Dockerfile to
|
||||||
|
move the configure and make commands into start.sh, and then use a volume mount
|
||||||
|
to cache the build directory (I think it's ```/tmp```) on your host filesystem.
|
||||||
|
This would be really useful for a developer, and would remove the annoying build
|
||||||
|
problem, but some of the Docker push/pull benefits would be lost.
|
||||||
|
|
||||||
|
Docker containers can be both CPU and memory limited, so this can be a practical
|
||||||
|
method to compile or run multiple development builds of ZoneFinder simultaneously
|
||||||
|
without taxing your host system.
|
||||||
|
|
||||||
## Use Cases
|
## Use Cases
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
- Describe how to connect to monitors by mounting devices
|
||||||
|
- Create a 'development' dockerfile to remove the need to rebuild the entire project
|
||||||
|
after each small change
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<VirtualHost *:80>
|
||||||
|
DocumentRoot /var/www/zm
|
||||||
|
DirectoryIndex index.php
|
||||||
|
|
||||||
|
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
|
||||||
|
<Directory "/usr/lib/cgi-bin">
|
||||||
|
AllowOverride None
|
||||||
|
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
</VirtualHost>
|
|
@ -2,7 +2,24 @@
|
||||||
|
|
||||||
# Start MySQL
|
# Start MySQL
|
||||||
/usr/bin/mysqld_safe &
|
/usr/bin/mysqld_safe &
|
||||||
sleep 5
|
|
||||||
|
# Give MySQL time to wake up
|
||||||
|
SECONDS_LEFT=120
|
||||||
|
while true; do
|
||||||
|
sleep 1
|
||||||
|
mysqladmin ping
|
||||||
|
if [ $? -eq 0 ];then
|
||||||
|
break; # Success
|
||||||
|
fi
|
||||||
|
let SECONDS_LEFT=SECONDS_LEFT-1
|
||||||
|
|
||||||
|
# If we have waited >120 seconds, give up
|
||||||
|
# ZM should never have a database that large!
|
||||||
|
# if $COUNTER -lt 120
|
||||||
|
if [ $SECONDS_LEFT -eq 0 ];then
|
||||||
|
return -1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Create the ZoneMinder database
|
# Create the ZoneMinder database
|
||||||
mysql -u root < db/zm_create.sql
|
mysql -u root < db/zm_create.sql
|
||||||
|
@ -10,9 +27,6 @@ mysql -u root < db/zm_create.sql
|
||||||
# Add the ZoneMinder DB user
|
# Add the ZoneMinder DB user
|
||||||
mysql -u root -e "grant insert,select,update,delete,lock tables,alter on zm.* to 'zm'@'localhost' identified by 'zm'"
|
mysql -u root -e "grant insert,select,update,delete,lock tables,alter on zm.* to 'zm'@'localhost' identified by 'zm'"
|
||||||
|
|
||||||
# Install the ZoneMinder apache vhost file
|
|
||||||
wget --quiet https://raw.github.com/kylejohnson/puppet-zoneminder/master/files/zoneminder -O /etc/apache2/sites-enabled/000-default
|
|
||||||
|
|
||||||
# Restart apache
|
# Restart apache
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
|
|
||||||
|
@ -20,5 +34,4 @@ service apache2 restart
|
||||||
/usr/local/bin/zmpkg.pl start
|
/usr/local/bin/zmpkg.pl start
|
||||||
|
|
||||||
# Start SSHD
|
# Start SSHD
|
||||||
mkdir /var/run/sshd
|
|
||||||
/usr/sbin/sshd -D
|
/usr/sbin/sshd -D
|
||||||
|
|
Loading…
Reference in New Issue