-
Install Docker 1.8 or above. The provided dockerfiles are dependent on Docker networking which may not work with the older Docker.
-
cd
to the docker directory. The following instructions assume that your current directory istinode_root_directory/docker
, wheretinode_root_directory
is the directory where you cloned the https://github.com/tinode/chat depository. -
Create a bridge network. It's used to connect application containers with the database container.
$ docker network create tinode-net
-
Decide which database backend you want to use: RethinkDB (default) or MySQL (experimental). Run the selected database container, attaching it to
tinode-net
network:- 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.
- 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
ormysql
in the--name
assignment is important. It's used by other containers as a database's host name. -
Build the initializer image for the selected database:
- RethinkDB
$ docker build --tag=tinode-init-db init-db
- MySQL
$ docker build --tag=tinode-init-db --build-arg TARGET_DB=mysql init-db
-
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 likebase64 <(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.
-
Build the Tinode server image. This image also includes the web app:
- RethinkDB
$ docker build --tag=tinode-srv tinode-server
- MySQL
$ docker build --tag=tinode-srv --build-arg TARGET_DB=mysql tinode-server
-
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 aSNOWFLAKE_UID_KEY
at step 5, you must provide the same key at this step too. -
Test the installation by pointing your browser to http://localhost:6060/x/.
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
See instructions.