How to run the JIT backend with Docker
This guide will show you how you can run the JIT backend with Docker in a single instance deployment. This is best suited for running JIT locally during development. It can be used to deploy on any infrastructure, but since it does not scale it can only handle a limited set of simultaneous users.
Prerequisites
You need docker installed, visit https://docs.docker.com/get-docker/ to get instructions for your operating system.
You also need credentials to our docker image repository codemill-docker.jfrog.io.
Test that your docker credentials are working, type this in your terminal:
docker login codemill-docker.jfrog.io
You will be prompted for your username and password. You will get a message that says: Login Succeeded if successful. If you were unsuccessful, please double-check your username and password and try again.
After you are logged in, make sure you have access rights to the docker images that we are going to use, by trying to pull (download) the images:
docker pull codemill-docker.jfrog.io/accurate-player/accurate-player-jit/jit-orchestrator:latest
docker pull codemill-docker.jfrog.io/accurate-player/accurate-player-jit/jit:latest
Make sure you did not get any error messages.
Run the backend
Now we have to set up some environment variables that the image requires. Create a file called .env in a folder of your chosing:
mkdir backend
cd backend
touch .env
Edit the contents of the file using the editor of your choice and insert this content:
DOCKER_REGISTRY_USERNAME=<insert your docker username here>
DOCKER_REGISTRY_PASSWORD=<insert your docker password here>
PUBLIC_IP=<insert your public ip here>
Example:
echo "DOCKER_REGISTRY_USERNAME=myusername" >> .env
echo "DOCKER_REGISTRY_PASSWORD=mypassword" >> .env
echo "PUBLIC_IP=$(curl -s ipinfo.io/ip)" >> .env
Now we are ready to start the backend service with docker:
docker run \
--add-host=host.docker.internal:host-gateway \
--volume /var/run/docker.sock:/var/run/docker.sock \
--label jit-orchestrator \
--rm \
--cap-add SYS_ADMIN \
--cap-add SYS_RESOURCE \
--security-opt apparmor:unconfined \
--env-file .env \
--init \
-p 8080:8080 \
codemill-docker.jfrog.io/accurate-player/accurate-player-jit/jit-orchestrator:latest
You may need to add --platform linux/amd64 as an argument if you are running on an ARM based cpu, like Apple M series.
This starts the JIT Orchestrator on localhost:8080, and it should be reachable from http://localhost:8080. You can try to reach it by calling the healthcheck endpoint:
curl http://localhost:8080/healthcheck
It should respond with status code 200 and OK in the response body.
We may also add the --turn argument (after the image name) when starting the image in order to start a STUN/TURN server on the side. This is needed to establish WebRTC connections. The turn server starts at stun:localhost:3478. You can also run without this flag and use any of the free alternatives listed here.
Now you have a running JIT backend!
Tips & tricks
-
If you are going to run this in a more permanent setting it's recommended to lock down the version you are running. This can be done by starting the JIT Orchestrator with a fixed version,
1.0.0in this case:docker run \
<... all your other options ...> \
codemill-docker.jfrog.io/accurate-player/accurate-player-jit/jit-orchestrator:1.0.0And by setting these environment variables in addition to the ones already set above. In this example we lock it to version
1.0.0:JIT_IMAGE=codemill-docker.jfrog.io/accurate-player/accurate-player-jit/jit:1.0.0
JIT_INSTANCE_AGENT_IMAGE=codemill-docker.jfrog.io/accurate-player/accurate-player-jit/jit-orchestrator:1.0.0 -
If you run the JIT behind a firewall, you'll need to expose the ports to the Orchestrator and to the JIT nodes for the clients. See
JIT_ORCHESTRATOR_PORT(TCP),JIT_CONTAINER_PORT_MIN-JIT_CONTAINER_PORT_MAX(UDP).
Next steps
You can test your backend right away using Accurate.Video Validate.
You'll find more details in our guide on running JIT in Validate.
If you are building a frontend application you should continue to our guide on building a frontend using Accurate Player SDK and JIT.
To learn more about how JIT works we recommend that you check out the Architectural overview and reference documentation for the docker containers.