Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 3.6 KB

README.md

File metadata and controls

83 lines (62 loc) · 3.6 KB

Using Docker to run Tinode

  1. Install Docker 1.8 or above. The provided dockerfiles are dependent on Docker networking which may not work with the older Docker.

  2. cd to the docker directory. The following instructions assume that your current directory is tinode_root_directory/docker, where tinode_root_directory is the directory where you cloned the https://github.com/tinode/chat depository.

  3. Create a bridge network. It's used to connect application containers with the database container.

    $ docker network create tinode-net
    
  4. Decide which database backend you want to use: RethinkDB (default) or MySQL (experimental). Run the selected database container, attaching it to tinode-net network:

    1. RethinkDB: If you've decided to use RethinkDB backend, run the official RethinkDB Docker container:
    $ docker run --name rethinkdb --network tinode-net -d rethinkdb:2.3
    

    See instructions for more options.

    1. MySQL: If you've decided to use MySQL backend, run the official MySQL Docker container:
    $ docker run --name mysql --network tinode-net --env MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5.7
    

    See instructions for more options.

    The name rethinkdb or mysql in the --name assignment is important. It's used by other containers as a database's host name.

  5. Build the initializer image for the selected database:

    1. RethinkDB
    $ docker build --tag=tinode-init-db init-db
    
    1. MySQL
    $ docker build --tag=tinode-init-db --build-arg TARGET_DB=mysql init-db
    
  6. Run the container to initialize the tinode database:

    $ docker run --rm --name tinode-init-db --network tinode-net tinode-init-db
    

    Optionally you may want to provide a UID encryption key as --env SNOWFLAKE_UID_KEY=base64+encoded+16+bytes=. On most Unix-like systems you can generate such a unique key by executing something like base64 <(head -c 16 /dev/random).

    The system uses snowflake to generate unique IDs for values like user IDs and topic names. To make them unpredictable it encrypts them with XTEA. If you don't provide the key, a default one (la6YsO+bNX/+XIkOqc5Svw==) will be used. As a result the IDs will be easily guessable (but still not sequential).

    At this point the database is initialized and loaded with test data. No need to do this again unless you want to reset the data or delete/recreated the DB container.

  7. Build the Tinode server image. This image also includes the web app:

    1. RethinkDB
    $ docker build --tag=tinode-srv tinode-server
    
    1. MySQL
    $ docker build --tag=tinode-srv --build-arg TARGET_DB=mysql tinode-server
    
  8. Run Tinode server:

    $ docker run -p 6060:18080 -d --name tinode-srv --network tinode-net tinode-srv
    

    The port mapping -p 6060:18080 tells Docker to map container's port 18080 to host's port 6060 making server accessible at http://localhost:6060/. If you provided a SNOWFLAKE_UID_KEY at step 5, you must provide the same key at this step too.

  9. Test the installation by pointing your browser to http://localhost:6060/x/.

Optional

Resetting the data

If you want to reset the data in the database, shut down the server container

$ docker stop tinode-srv

then repeat step 6 then restart the server

$ docker start tinode-srv

Running the chatbot

See instructions.