tackle

alt tackle

Tackle is a local development tool for multiple Docker Compose projects interconnected via Service Discovery mechanism. Host machine and containers use Consul Docker container as DNS resolver and Service Discovery agent. Registrator is used to register docker containers to Consul. Docker and Docker Compose are installed during installation steps.

Install

  • Install Ansible.
  • Install bundle if not already gem install bundle
  • run in the project's folder bundle install
  • run in the project's folder ./tackle install it will run Ansible's script to install Docker and Docker Compose.

What it does?

  • Adds default options for new Docker's container (sets Consul as DNS for container). Containers should see each other using container name.
  • Adds Consul DNS for host machine
  • Creates Consul container
  • Creates Registrator container
  • Parses tackle.yml and runs docker-compose up -d or docker-compose stop for each project.

Commands

  • help - Show short help
  • up [PROJECT] - Runs Consul, Registrator and Docker Compose for projects in tackle.yml
  • down [PROJECT] - Stops Consul, Registrator and Docker Compose for projects in tackle.yml
  • down [PROJECT] - Runs down and up commands for projects in tackle.yml
  • setup [PROJECT] - Run setup steps for projects in tackle.yml
  • install - Install Docker and Docker Compose
  • list - lists active projects
  • on [PROJECT] - activate a project
  • off [PROJECT] - deactivate a project

Example ./tackle up

Consul UI is available at http://localhost:8500/ui/#/dc1/services

tackle.yml

project1:
  root: /var/www/project1
  setup:
    - docker-compose run web bundle install
    - docker-compose run web rake db:create db:migrate db:seed

project2:
  root: /var/www/project2
  active: false

Requirements

  • Ruby
  • Ansible

Creating a discoverable containers

When running any container via docker, which exposes port, it will be registered in Consul. You can access it via container_name.service. To give your service a name you can follow the next example in docker-compose.yml

web:
  build: .
  command:  bundle exec rails s -p 3000 -b '0.0.0.0'

  environment:
    RAILS_ENV: development
    SERVICE_NAME: myservicename

Note that SERVICE_NAME should be alphanumerical and dash. No underscore or dots are allowed by DNS parser.

Thx

Many thanks to IFTTT/dash for mac version code inspiration.