Skip to content
Justin Brooks edited this page Apr 9, 2019 · 44 revisions

Contents

Prerequisites

Docker and docker-compose makes it easier to create, deploy and run applications. By shipping the required packages and libraries in Docker containers, the worry for compatibility becomes obsolete. As such, COCO Annotator provides a production and development build. In order to use theses builds Docker and docker-compose is required. You can follow their documentation for installation in the links referenced.

Currently, Docker is the only supported method for installation. If an alternative method is required, the Dockerfiles can act as a break-down for the required environment.

Downloading

The latest version can be downloaded from GitHub or by executing the commands shown in the listing below.

Listing 1: Download COCO Annotator via command line

$ git clone https://github.com/jsbroks/coco-annotator
$ cd coco-annotator

Installing

It is recommend to run the production build as it is designed for stability and scaling. Also note the development build is dependent on ports and can break API calls if they are changed without the proper adjustments.

Production Build

Production build is the most stable and suitable for supporting a large user base. To execute the production build in the root directory of the cloned repository as follows:

Listing 2: Docker command for production build

$ docker-compose up

This command will pull the latest stable image from dockerhub, which pre-complied with all dependencies. The instance can be found at http://localhost:5000/.

More information can be found in the Implementation Section.

Development Build

Development build provides hot reloading and serves the frontend and backend on two different ports. To execute the development build, using the docker-compose.dev.yml file as follows:

Listing 3: Docker command for development build

$ docker-compose -f docker-compose.dev.yml up --build

Using -f to specify the docker compose file and --build to build the project.

The frontend instance can be found at http://localhost:5000/ and backend at http://localhost:5000/api/.

More information can be found in the Implementation Section.

Stopping Container

The docker container can be stopped by navigating to the applications directory and executing the command shown in the listing below.

Listing 4: Docker command for stopping container

$ docker-compose down

The process is independent of which build is currently running.

Updating

Before updating, ensure the container has stopped running.

Listing 7: Updating docker image

$ docker-compose pull

The docker image containers all of the docker files and does not require the repository to be updated. If you would like to update the files as well use:

Listing 6: Updating the git repository

$ git pull

Database Backups

Creating backups of your datasets is always recommend for many reasons. In order to successfully backup all data create by this annotation tool, it will require completion in two parts. First, the user can create a copy of the /datasets/ directory found at the root of the project. To backup a data volume you can run a new container using the volume you want to backup and executing the tar command to produce an archive of the volume content as described in the docker user guide.

Dedicated Server/VPS Setup

One of COCO Annotator's greatest feature is its ability to scale, allowing users to create a centralized place for datasets and provide external access for outsourcing. This section will explain how to set up an instance on a server for external access. A recommended server specification is 2GB RAM and 2 CPU Cores for running a basic instance. If the annotator is to be used with images larger then 1 megapixel, increasing the RAM can greatly help performance.

In order to provide a secure set up https (vs normal http) is strongly recommend as all communications between the user's browser and the website are encrypted. This guide shows setting up Lets Encrypt and Nginx to create an https between client and server on a sub-domain.

Root access to the server is required to modify files created by the docker image.

Setting up Lets Encrypt and Nginx

Let's Encrypt is a free, and automated application for creating a secure sockets layer between the client and server. Nginx is a high-performance load balance web-server for handle requests and domains.

Using the docker-compose provided below a user can get a basic set up running with both Nginx and Let's Encrypt.

version: 3
services:
    letsencrypt:
        image: linuxserver/letsencrypt
        container_name: letsencrypt
        network_mode: host
        restart: always
        ports:
            - 80:80
            - 443:443
        volumes:
            - ./config:/config
        environment:
            # Domain name
            - URL=example.com
            - TZ=America/New_York
            - PGID=1000
            - PUID=1000
            # Subdomains to encrypt
            - SUBDOMAINS=www,annotator
        cap_add:
            - NET_ADMIN

Example Nginx configuration for passing the annotator though /config/nginx/site-confs/default.

server {
        listen 80;
        server_name _;
        return 301 https://$host$request_uri;
}

server {
        listen 443 ssl;
        server_name _;

        root /config/www;
        include /config/nginx/ssl.conf;

        location / {
                index index.html index.htm;
                include /config/nginx/proxy.conf;
        }
}

server {
        listen 443 ssl;
        server_name annotator.*;

        include /config/nginx/ssl.conf;

        location / {
                include /config/nginx/proxy.conf;
                proxy_pass http://localhost:5000/;
        }
        location /socket.io {
                include /config/nginx/proxy.conf;
                proxy_buffering off;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_pass http://localhost:5000/socket.io;
        }
}