Deploying Standalone Tango
This is a guide to setup a fully self-sufficient Tango deployment environment out-of-the-box using Docker. The suggested deployment pattern for Tango uses Nginx as a proxy and Supervisor as a process manager for Tango and all its dependencies. All requests to Nginx are rerouted to a Tango process.
- Nginx default port - 8600
- Tango ports - 8610, 8611
- Redis port - 6379
- You can change any of these in the respective config files in
deployment/config/before you build the
Clone the Tango repo
$ git clone https://github.com/autolab/Tango.git; cd Tango
config.pyfile from the given template.
$ cp config.template.py config.py
Install docker on the host machine by following instructions on the docker installation page. Ensure docker is running:
$ docker ps # CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Run the following command to build the Tango deployment image.
$ docker build --tag="tango_deployment" .
Ensure the image was built by running.
$ docker images # REPOSITORY TAG IMAGE ID CREATED SIZE # tango_deployment latest 3c0d4f4b4958 2 minutes ago 742.6 MB # ubuntu 15.04 d1b55fd07600 4 minutes ago 131.3 MB
Run the following command to access the image in a container with a bash shell. The
-pflag will map
nginxPorton the docker container to
localPort(8610 recommended) on your local machine (or on the VM that docker is running in on the local machine) so that Tango is accessible from outside the docker container.
$ docker run --privileged -p <localPort>:<nginxPort> -it tango_deployment /bin/bash
Set up a VMMS for Tango within the Docker container.
Run the following command to start supervisor, which will then start Tango and all its dependencies.
$ service supervisor start
Check to see if Tango is responding to requests
$ curl localhost:8610 # Hello, world! RESTful Tango here!
Once you have a VMMS set up, leave the tango_deployment container by typing
exitand once back in the host shell run the following command to get the name of your production container.
$ docker ps -as # CONTAINER ID IMAGE COMMAND NAMES SIZE # c704d45c3737 tango_deployment "/bin/bash" erwin 40.26 MB The container created in this example has the name `erwin`.
The name of the production container can be changed by running the following command and will be used to run the container and create services.
$ docker rename <old_name> <new_name>
To reopen the container once it has been built use the following command. This will reopen the interactive shell within the container and allow for configuration of the container after its initial run.
$ docker start erwin $ docker attach erwin
Once the container is set up with the autograding image, and the VMMS configured with any necessary software/environments needed for autograding (java, perl, etc), some configurations need to be changed to make the container daemon ready. Using the
CONTAINER IDabove, use the following commands to modify that containers
$ sudo ls /var/lib/docker/containers c704d45c37372a034cb97761d99f6f3f362707cc23d689734895e017eda3e55b $ sudo vim /var/lib/docker/containers/c704d45c37372a034cb97761d99f6f3f362707cc23d689734895e017eda3e55b/config.v2.json
Edit the "Path" field in the config.v2.json file from "/bin/bash" to "/usr/bin/supervisord" and save the file. Run the following commands to verify the changes were successful. The COMMAND field should now be "/usr/bin/supervisord"
$ service docker restart $ docker ps -as # CONTAINER ID IMAGE COMMAND NAMES SIZE # c704d45c3737 tango_deployment "/usr/bin/supervisord" erwin 40.26 MB
At this point when the container is started, the environment is fully set up and will no longer be an interactive shell. Instead, it will be the supervisor service that starts Tango and all its dependencies. Test this with the following commands and ensure Tango is functioning properly.
$ docker start erwin # (Test tango environment) $ docker stop erwin
Test the setup by running sample jobs using the testing guide.
The following steps are optional and should only be used if you would like the Tango container to start on system boot.
To ensure Tango starts with the system in the production environment, the container needs to be configured as a service. Below is a sample service config file that needs to be changed to suit your environment and placed in
/etc/systemd/system/. The file should be named
<name>.service. For this example, it is
[Unit] Description=Docker Service Managing Tango Container Requires=docker.service After=docker.service [Service] Restart=always ExecStart=/usr/bin/docker start -a erwin ExecStop=/usr/bin/docker stop -t 2 erwin [Install] WantedBy=default.target
Test and ensure the service was set up correctly. The service should start successfully and remain running.
$ systemctl daemon-reload $ service erwin start $ service erwin status
Enable the service at system startup and reboot and ensure it starts with the host.
$ systemctl enable erwin.service $ sudo reboot # (Server Reboots) $ service erwin status