-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Docker
In this example, we will be spinning up a brand new container with the latest ZoneMinder code. At the end of the example, you'll be able to access the ZoneMinder container via the forwarded ports.
-
Build the ZoneMinder image. This may take a while.
sudo docker build -t='kylejohnson/release-1.27' github.com/ZoneMinder/ZoneMinder
The -t flag allows you to 'tag' your image. In this example, I am building a container for myself, for use with the 1.27 release.
-
Run (start) the ZoneMinder container.
CID=$(sudo docker run -P -d -t kylejohnson/release-1.27)
- The -P flag forwards any ports that are
EXPOSE
'd in the Dockerfile (80 and 22). - The -d flag detaches the container and runs it in the background.
- The -t flag tells docker to allocate a pseudo TTY.
- The -P flag forwards any ports that are
-
Find out which ports your container is listening on. You can now access ZoneMinder, via ssh or http, on the ports listed in those last two commands.
kjohnson@lxc01:~/$ sudo docker port $CID 22
0.0.0.0:49155
kjohnson@lxc01:~/$ sudo docker port $CID 80
0.0.0.0:49156
In this example we will use docker to build a new zoneminder 'image' for each change that we make, in order to test our code in a clean environment.
We will clone a fork of the zoneminder repo, edit the dockerfile to point to our fork of the code on github, make changes, push them to our fork, and then build from the local dockerfile - against our fork of the zoneminder repo.
-
Clone your fork of the ZoneMinder repo
git clone git@github.com:kylejohnson/ZoneMinder.git
-
Edit the Dockerfile to point to our fork
kjohnson@lxc01:~/ZoneMinder$ git diff Dockerfile
diff --git a/Dockerfile b/Dockerfile
index 32cab3e..2466dff 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,11 +15,14 @@ RUN apt-get upgrade -y
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-
# Grab the latest ZoneMinder code
-RUN git clone https://github.com/ZoneMinder/ZoneMinder.git
+RUN git clone https://github.com/kylejohnson/ZoneMinder.git
# Change into the ZoneMinder directory
WORKDIR ZoneMinder
+# Check out the release-1.27 branch
+RUN git checkout release-1.27
+
# Setup the ZoneMinder build environment
RUN aclocal && autoheader && automake --force-missing --add-missing && autoconf
- Make changes and push to your fork. In this case I am testing different popup sizes for the flat skin.
git add web/skins/flat/js/skin.js
git commit -m 'Fix popup sizes in flat skins. Fixes #331'
git push origin release-1.27
-
Build the local Dockerfile, which points to our fork. sudo docker build -t='kylejohnson/release-1.27-flat' .
-
Run the built docker image
CID=$(sudo docker run -P -d -t kylejohnson/release-1.27-flat)
-
See which port it is listening on
sudo docker port $CID 80 0.0.0.0:49158
-
Test your changes by connecting to that host on port 49158
-
Looks good? Create a pull request from your fork to master.