Docker Installation

Mozillians development environment can be installed using docker. This way we run Mozillians and all it’s dependencies as docker containers. Here you can find more info about what docker is.

Dependencies

  1. You need to install docker in your system. The installation guide covers many operating systems but for now we only support Linux and Mac OS X. Version required: 1.3.1 or newer.
  2. We are using an orchestration tool for docker called docker-compose that helps us automate the procedure of initiating our docker containers required for development. Installation instructions can be found in Compose’s documentation. Version required: 1.0.1 or newer.

Running Docker on Mac

Here are some notes regarding running Docker on Mac.

  • Docker cannot run natively on Mac because it is based on a Linux kernel specific feature called LXC.
  • When running docker in Mac via boot2docker you are running a lightweight Linux VM in Virtualbox that hosts the docker daemon and the LXC containers.
  • We are running docker client in our host system that connects to the docker daemon inside boot2docker VM.
  • We are using docker’s volume sharing feature in order to share the source code with the Mozillians container. This is not directly supported in Mac. As a workaround boot2docker implements this feature by sharing the folder with Virtualbox first.
  • The extra layer that we are adding using Virtualbox might cause some performance issues. This is a trade-off for having an easily reproducible stack without installing everything manually.

More information regarding boot2docker can be found in the documentation.

Here are some extra steps in order to run Mozillians on Mac:

  1. Make sure boot2docker is initialized:

    $ boot2docker init
    
  2. Make sure boot2docker VM is up and running:

    $ boot2docker up
    
  3. Export DOCKER_HOST variables using the following command:

    $ $(boot2docker shellinit)
    

Note

You need to make sure to run $(boot2docker shellinit) in each new shell you are using, or export it globally in order not to repeat this step every time you are working on mozillians.

Building mozillians

  1. Fork the main Mozillians repository.

  2. Clone your fork to your local machine:

    $ git clone git@github.com:YOUR_USERNAME/mozillians.git mozillians
    (lots of output - be patient...)
    $ cd mozillians
    
  3. Configure your local Mozillians installation:

    $ cp mozillians/env-dist mozillians/.env
    
  4. Start MySQL and ElasticSearch containers:

    $ docker-compose up -d db es
    
  5. Update the product details:

    $ docker-compose run web python manage.py update_product_details -f
    
  6. Create the database tables and run the migrations:

    $ docker-compose run web python manage.py migrate --noinput
    
  7. Import cities_light details:

    $ docker-compose run web python manage.py cities_light
    
  8. Load the timezone tables to MySQL:

    $ docker-compose run db /bin/bash
    shell> mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -uroot -proot -h mozillians_db_1 mysql
    
  9. Create a superuser:

    $ docker-compose run web python manage.py createsuperuser
    
  10. Give permissions to the user:

    $ docker-compose run web ./scripts/su.sh
    
  11. Run mozillians:

    docker-compose up
    
    1. Load http://127.0.0.1:8000 or (for Mac users only) <IP>:8000 where <IP> is the one returned by boot2docker ip command.

    2. Sign in with persona to create your profile.

    3. Stop the server with Ctrl^C.

      Note

      In case this command doesn’t work, you can run ./scripts/su.sh inside the container. In order to get shell access please run docker-compose run web /bin/bash. To login to mozillians.org for dev purposes please visit http://127.0.0.1:8000/admin and login with the credentials issued in the previous step. The signin button doesn’t work locally.

Running mozillians

  1. Run Mozillians:

    $ docker-compose up
    (lots of output - be patient...)
    
  2. Develop!