Supplejack Docker in Linux - OurDigitalWorld/supplejack-ember GitHub Wiki

Step 1: Install Dependencies

Dependencies for Supplejack Docker include Virtualbox, Docker, Docker Machine, and Docker Compose. To start, open a terminal window (Ctrl + Alt + T). Then enter each of the commands below (each command starts with $. Omit this symbol when entering the command. Handy tip: You can paste code from your clipboard into the terminal with Ctrl + Shift + V. Virtualbox

$ echo "deb http://download.virtualbox.org/virtualbox/debian xenial contrib" | sudo tee /etc/apt/sources.list
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install virtualbox-5.1

Note: At this point, if you get an error that starts with Some packages could not be installed, try the following:

Open the program “Software & Updates” On the “Ubuntu Software” tab, make sure all of the boxes are checked. Try running the final command to install Virtualbox again!

Docker

$ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
$ sudo apt-get update
$ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual              
$ sudo apt-get update
$ sudo apt-get install docker-engine
$ sudo service docker start

Docker Machine

$ curl -L https://github.com/docker/machine/releases/download/v0.9.0-rc2/docker-machine-`uname -s`-`uname -m` > /tmp/docker-machine && chmod +x /tmp/docker-machine && sudo cp /tmp/docker-machine /usr/local/bin/docker-machine

Docker Compose

$ curl -L https://github.com/docker/compose/releases/download/1.10.0/docker-compose-`uname -s`-`uname -m` > /tmp/docker-compose && chmod +x /tmp/docker-compose && sudo cp /tmp/docker-compose /usr/local/bin/docker-compose

Step 2: Set up Git Authentication

In this step, you configure the Git Authentication on your computer to enable you to clone git repositories. In a terminal window, enter the commands below, replacing [GitHub email address] with the email address associated with your GitHub account. If you don’t have a GitHub account, create one first.

$ ssh-keygen -t rsa -b 4096 -C "[GitHub email address]"
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
$ sudo apt-get install xclip
$ xclip -sel clip < ~/.ssh/id_rsa.pub

After entering these commands, open the web browser of your choice, sign into your GitHub account, then go to “Settings” -> “SSH and GPG Keys” -> “New SSH Key”. Give the new key whatever title you’d like, then paste the content of your clipboard into the “Key” section. The content you paste in should look similar to this:

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU
GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3
Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA
t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En
mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx
[email protected]

After pasting in your key, click “Add SSH Key”.

Step 3: Set up work directory and clone Supplejack Docker

In the terminal, enter the following commands, replacing [username]with your linux username (you chose this while installing Ubuntu).

$ cd /home/[username]/Documents
$ mkdir supplejack && cd supplejack
$ git clone --recursive [email protected]:digitalnz/supplejack_docker.git

Step 4: Install Supplejack Docker

To install Supplejack Docker, enter the following terminal commands, starting in your work directory (/home/[username]/Documents/supplejack).

$ cd supplejack_docker
$ docker-machine create --driver=virtualbox supplejack-docker
$ docker-machine start supplejack-docker
$ eval $(docker-machine env supplejack-docker)

It’s normal for several of these commands to take a long time. After entering these commands, open your file manager (Ubuntu’s default file manager is called ‘Files’), then: navigate to /Home/Documents/supplejack/supplejack_docker/manager/config make a copy of the file application.yml.docker, and rename it application.yml At this point, you can also add the rack-cors configuration (from step 4 of the client install) After doing this, enter in the same terminal window from before:

$ docker-compose build

After this final command finishes (which may take several minutes), Supplejack Docker should be installed! Note: The build process involves fetching files from a number of different directories on the internet. If any of these processes fail, the build will be unsuccessful. If you encounter any error messages that start with E: Failed to fetch..., you will likely need to try building again until you don’t get any errors.

Step 5: Testing install

Start up Supplejack Docker and make sure it’s running successfully. To start up supplejack, in the terminal type (this will take awhile as well):

$ docker-compose up

After giving the Docker containers a minute to start up, open a new terminal window (Ctrl + Shift +T), and enter the following commands

$ eval $(docker-machine env supplejack-docker)
$ docker ps

If Supplejack Docker was installed correctly, you should see something like:

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                    NAMES                                                              
b82c59b64d2e        supplejackdocker_sidekiq   "bundle exec sidekiq"    57 seconds ago      Up 56 seconds                                sidekiq                                                            
3ed5cf88d125        supplejackdocker_worker    "bundle exec rails s "   57 seconds ago      Up 56 seconds       0.0.0.0:3002->3000/tcp   worker                                                             
7e92bb3df879        supplejackdocker_manager   "bundle exec rails s "   57 seconds ago      Up 56 seconds       0.0.0.0:3001->3000/tcp   manager                                                            
ae32635f4802        supplejackdocker_api       "bundle exec rails s "   58 seconds ago      Up 57 seconds       0.0.0.0:3000->3000/tcp   api                                                                
dad90c3e0039        redis:2.8                  "docker-entrypoint.sh"   58 seconds ago      Up 57 seconds       0.0.0.0:6379->6379/tcp   redis                                                              
a4e536734a7b        supplejackdocker_solr      "java -jar start.jar"    59 seconds ago      Up 57 seconds       0.0.0.0:8983->8983/tcp   solr                                                               
47fba6738e23        mongo:2.6.12               "/entrypoint.sh mongo"   17 hours ago        Up 57 seconds       27017/tcp                supplejackdocker_mongodb_1

Step 6: Seeding Data

Once Supplejack Docker has been successfully installed, it needs to be seeded with default users before you can start working with it. Enter the following commands:

$ docker exec -it manager rake docker:seed
$ docker exec -it worker rake docker:seed
$ docker exec -it api rake docker:seed

This will generate the following users and keys:

Manager:    
    email: [email protected]
    password: password
    authentication_token: 'managerkey'

Worker:
    authentication_token: 'workerkey'

API:
    api_key: 'apikey'

To access the components, you need to use your Docker machine’s host IP address:

$ echo $DOCKER_HOST
tcp://192.168.99.100:2376

Use the appropriate ports to access each component:


api: http://192.168.99.100:3000/records.json?api_key=apikey
manager: http://192.168.99.100:3001
worker: http://192.168.99.100:3002
sidekiq: http://192.168.99.100:3002/sidekiq
solr: http://192.168.99.100:8983/solr

Source: https://github.com/DigitalNZ/supplejack_docker

You should now have a working installation of Supplejack Docker! At this point, before working on the client, you may want to update the schema, and some data sources / parsers.