Skip to content
Chris Mullins edited this page May 7, 2017 · 16 revisions

Examples

Create a pristine test environment

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.

  1. Build the ZoneMinder image. This may take a while.

    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.

  2. Run (start) the ZoneMinder container.

     CID=$(docker run -P -d -t kylejohnson/release-1.27)
    
    • The -P flag forwards any ports that are EXPOSE'd in the Dockerfile (80).
    • The -d flag detaches the container and runs it in the background.
    • The -t flag tells docker to allocate a pseudo TTY.

Or if you are using nginx-proxy don't forget to set VIRTUAL_HOST environment with your domain where you want to deploy zoneminder

CID=$(docker run -e VIRTUAL_HOST=zm.yourdomain.com -P -d -t kylejohnson/release-1.27)
  1. Find out which ports your container is listening on. You can now access ZoneMinder over http, on the port output by the following command:
kjohnson@lxc01:~/$ docker port $CID 80
0.0.0.0:49156

Testing changes

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, make changes, and then build from the local Dockerfile - against our clone of the zoneminder repo.

  1. Clone your fork of the ZoneMinder repo
git clone [email protected]:kylejohnson/ZoneMinder.git
  1. Checkout the relevant branch
kjohnson@lxc01:~/ZoneMinder$ git checkout my_feature_branch
  1. Make changes locally, no need to push or commit. 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'
  1. Build the local Dockerfile in our fork.
docker build -t='kylejohnson/release-1.27-flat' .
  1. Run the built docker image
CID=$(docker run -P -d -t kylejohnson/release-1.27-flat)
  1. See which port it is listening on
docker port $CID 80
0.0.0.0:49158
  1. Test your changes by connecting to that host on port 49158

  2. Looks good? Create a pull request from your fork to master.