Viewu Server
Docker

Docker

Setup

The Viewu Server operates within a Docker container, with its Docker image available on https://hub.docker.com (opens in a new tab). The Viewu Server image is tagged for both amd64 (x86-64) and arm64 (Apple Silicon chips). Each image is compact in size, consuming minimal system memory, usually between 2 - 10MiB.

  • mjeoffline/viewu:amd64 => size 29.6MB
  • mjeoffline/viewu:arm64 => size 40.25MB

Choose the image and tag that matches your machine archetiect.


Photo

The preferred method for running the Viewu Server is through Docker Compose. Below is a sample docker-compose.yml file used for this purpose.

docker compose -f compose.yml up -d

The '-f' flag specifies the file name, while '-d' instructs Docker to run the container detached in the background. The 'up' command initiates the Docker container.

compose.yml

services:
  viewu:
    container_name: viewu
    restart: unless-stopped 
    image: mjeoffline/viewu:amd64
    environment:
      MQTT_PORT: 1883
      MQTT_IP: 127.0.0.1  
      # For anonymous connections, leave MQTT_USER and MQTT_PASSWORD blank
      MQTT_USER: username_goes_here
      MQTT_PASSWORD: password_goes_here
  • MQTT_PORT: Port which MQTT broker runs on
  • MQTT_IP: Local network IP address which MQTT broker runs on
  • MQTT_USER: MQTT username
  • MQTT_PASSWORD: MQTT password

Notification Template Filtering

This is supported in Viewu Server version 2.6 and later.

Viewu notifications can be managed using the Notification Manager screen in Viewu. This helps reduce the number of notifications received and allows you to specify which events you get notifications for. To enable this screen, toggle the Noticiatin Manager field to on in Settings.

Each template string is separated by ::. A template is composed of one or more keys with a == and a string value list separated by a |. For example:

type==end, label==person|dog :: type==end, label==person, entered_zones==front_patio|front_close_sidewalk|front_far_sidewalk :: camera==side, entered_zones==side_gate|side_far_sidewalk

Values are separated by |, and == is used to compare key-value pairs.

The template type==end, label==person|dog will match on any event that has ended with where the label equals person or dog. The key name and values are case-sensitive.

Here are the fields you can filter on:

  • camera
  • label
  • current_zones
  • entered_zones
  • type == new|update|end

Filtering notifications based on the type field can significantly reduce noise and ensure users receive only the most relevant updates. Here’s how you can implement this in your code to filter messages based on the type field, ensuring that only messages with type == "new" or type == "end" trigger notifications (type==new|end). Including update will result in more notifications, so it is recommended not to filter on update.

Viewu Server will read and try to match the template. Once it finds a match, it will send a push notification and stop processing further templates. If it does not find a match, it will not send a push notification.

Note: If you are experimenting with different templates to find what works best for you, you may need to re-pair your phone each time you run Docker Compose.

Common CLI Commands

List the images

docker image ls

List all containers

docker ps -a

View log files for a container

docker logs container_id

View Stats for a container

docker stats

*Note you may need to use sudo to run the Docker commands

Information

Docker is a popular platform used for developing, shipping, and running applications in a containerized environment. A container is a lightweight, standalone, executable package that includes everything needed to run a piece of software, such as code, runtime, libraries, and dependencies. Docker provides tools and APIs for managing these containers efficiently.

Here's a breakdown of Docker's key components and functionalities:

  1. Docker Engine: The core of Docker, responsible for creating and managing containers. It consists of a daemon process (dockerd) running on the host system and a command-line interface (docker) for interacting with the daemon.

  2. Container: An instance of a Docker image that runs a specific application or service. Containers are isolated from one another and from the underlying host system, providing consistency and reproducibility across different environments.

  3. Docker Image: A lightweight, portable, and immutable snapshot of a container's filesystem and configuration. Images serve as templates for creating containers, containing everything needed to run an application, including code, dependencies, system libraries, and runtime environment.

  4. Dockerfile: A text file used to define the configuration and steps for building a Docker image. It specifies the base image, environment variables, commands, and other settings necessary to create the desired containerized application.

  5. Registry: A centralized repository for storing and distributing Docker images. The Docker Hub is the official public registry provided by Docker, but users can also set up private registries to store proprietary or sensitive images.

  6. Container Orchestration: Docker provides tools for orchestrating and managing clusters of containers at scale. Docker Swarm is Docker's built-in orchestration tool, while Kubernetes is a popular open-source alternative for container orchestration.

  7. Networking and Storage: Docker provides networking and storage solutions for connecting containers to each other and to external networks, as well as for persisting data within containers or across multiple containers.

Overall, Docker simplifies the development, deployment, and operation of applications by packaging them into lightweight and portable containers, enabling developers to build, ship, and run software reliably and efficiently across different environments.