Supplejack Docker in the cloud - OurDigitalWorld/supplejack-ember GitHub Wiki
For our demonstration, and to further our own understanding of Supplejack, we built an instance of Supplejack-Docker in DigitalOcean. The process would likely be very similar for AWS EC2 (or another provider)
Architect it!
We utilized a two "droplet" (server) system for our project. One droplet acts as file host [SJ1], allowing multi-users access to the files like record_schema.rb
, that would be regularly edited by multiple developers. The second droplet [SJ2] acts as the docker host (playing the role that Virtualbox does in the local deployment of Supplejack-Docker)
These droplets have the following specs:
- SJ1 8GB/80GB Ubuntu LEMP
- SJ2 8GB/80GB Ubuntu LEMP
Build it!
Build and secure an SJ1 server for yourself. Build only one server at this time. You can select the LEMP one-click app here to reduce your workload.
Follow until Step 4 in Supplejack-Docker in Linux. (We cloned the Supplejack-Docker repository into the home folder of a shared admin user account). This time after you move to the directory . . .
$ cd supplejack_docker
generate a DigitalOcean access token and create the new server by using the DigitalOcean driver instead of the VirtualBox one [you could use the AWS driver one too if that's how you roll]. Here's a list of drivers
docker-machine create --driver digitalocean --digitalocean-access-token=YOUR-ACCESS-TOKEN-HERE --digitalocean-size 8gb supplejack-docker
This will spin up a new droplet [SJ2] for you!
$ docker-machine start supplejack-docker
$ eval $(docker-machine env supplejack-docker)
ssh
into your new server [SJ2] with
docker-machine ssh supplejack-docker
[you run the docker commands from SJ1, and ssh into SJ2 to access the containers]
secure it like you did for SJ1, and install the remaining LEMP pieces.
Install it!
Exit SJ2 and continue with the install from SJ1. (Making sure you've made a copy of the file application.yml.docker
, and renamed it application.yml
you can also add the rack-cors configuration Step 4 of the Ember Client installation
$ 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.
$ docker-compose up
This will take a bit, when it's complete open a new terminal, and from the app root on SJ1 run:
$ eval $(docker-machine env supplejack-docker)
$ docker-machine ls
You should see:
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
supplejack-docker * digitalocean Running tcp://138.197.71.234:2376 v1.13.1
then run:
$ docker ps
If Supplejack Docker was installed correctly, you should see something like this: [except, of course these containers have been running for a while)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0914605735b1 supplejackdocker_api "bundle exec rails..." 2 weeks ago Up 2 weeks 0.0.0.0:3000->3000/tcp api
be79d619354e supplejackdocker_sidekiq "bundle exec sidekiq" 2 weeks ago Up 2 weeks sidekiq
65d603f7e928 supplejackdocker_manager "bundle exec rails..." 2 weeks ago Up 10 days 0.0.0.0:3001->3000/tcp manager
b6c106153e11 supplejackdocker_worker "bundle exec rails..." 2 weeks ago Up 2 weeks 0.0.0.0:3002->3000/tcp worker
dccf3fbd77b1 supplejackdocker_resque "bundle exec rake ..." 2 weeks ago Up 2 weeks resque
71787dd494ca supplejackdocker_scheduler "rake resque:sched..." 2 weeks ago Up 2 weeks scheduler
7446f4c07639 redis:2.8 "docker-entrypoint..." 4 months ago Up 2 weeks 0.0.0.0:6379->6379/tcp redis
b15001d545d4 supplejackdocker_solr "java -jar start.jar" 4 months ago Up 2 weeks 0.0.0.0:8983->8983/tcp solr
ad5d880180e3 mongo:2.6.12 "/entrypoint.sh mo..." 4 months ago Up 2 weeks 27017/tcp supplejackdocker_mongodb_1
Configure it!
Make sure your servers and ports can communicate with one another, by adjusting the ufw as needed. For our SJ1 we have:
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
22 ALLOW Anywhere
2376 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
2376 (v6) ALLOW Anywhere (v6)
and SJ2:
To Action From
-- ------ ----
2376 ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
22 ALLOW Anywhere
443 ALLOW Anywhere
2376 (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
Once Supplejack Docker has been successfully installed, it needs to be seeded with default users before you can start working with it. Again, from the app root on SJ1 enter the following commands:
$ eval $(docker-machine env supplejack-docker)
$ docker-machine ls
$ 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://SJ1-IP-ADDRESS:2376
Use the appropriate ports to access each component [assuming you've allowed them in ufw
]
api: http://SJ1-IP-ADDRESS:3000/records.json?api_key=apikey
manager: http://SJ1-IP-ADDRESS.100:3001
worker: http://SJ1-IP-ADDRESS:3002
sidekiq: http://SJ1-IP-ADDRESS:3002/sidekiq
solr: http://SJ1-IP-ADDRESS:8983/solr
That's it. Now go outside for a while.