Skip to content

Commit

Permalink
Merge pull request #15 from HumanDynamics/features/docker
Browse files Browse the repository at this point in the history
Fixed Ansible scripts to run hub code inside a docker
  • Loading branch information
OrenLederman authored Apr 22, 2017
2 parents 67071cf + e22d070 commit eaa52ff
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 24 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
= docker
# docker

== Development
## Development
For development, you can use the dev_ubuntu.yml (for linux, mac or windows) and dev_jessie.yml (if you are using raspberry pi). For exmaple:
docker-compose -f dev_ubuntu.yml up

By default, docker will start in standalone mode. However, you can override the default parameters using the run command:
By default, docker will start the hub in standalone mode. However, you can override the default parameters using the run command:
docker-compose -f dev_ubuntu.yml run openbadge-hub-py -m server pull

For convenience, we mount the local data, logs and config directories as volumes in docker. This allows easier access to the data generated in this mode.

== Production
TBD. Use docker-compose.yml. Don't forget to populate .env (see .env.sample)
## Production
For production, we use docker volumes to store the data (rather than using the host's dicrectories). It also automatically starts in server mode.

== Other useful commands
To set it up, create a .env file (use env.example as a template), and change the server address, port and key.

Next, run docker-compose (it will use docker-compose.yml as default) :
docker-compose up -d


## Other useful commands
* Gaining shell: docker-compose -f dev_ubuntu.yml run --entrypoint /bin/bash openbadge-hub-py
* Checking is the hub is running: docker-compose ps
4 changes: 2 additions & 2 deletions playbooks/badge_hub.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[program:badge_hub]
command=/home/pi/openbadge-hub-py/badge_hub.py -m server pull
command=docker-compose up
directory=/home/pi/openbadge-hub-py/
autostart=true
autorestart=unexpected

redirect_stderr=true
32 changes: 23 additions & 9 deletions playbooks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,50 @@
repo_url: git://github.com/HumanDynamics/openbadge-hub-py.git
dest_location: /home/{{user}}/openbadge-hub-py
remote_user: pi

tasks:
- name: Installing System Packages
apt: name={{ item }} state=present update_cache=yes
with_items:
- git
- libglib2.0-dev # From bluepy
- python-pip # From bluepy
- python-setuptools # For installing pip
- python-pip
- supervisor # for running the processes as deamons
- links2 # useful when setting up a device
become: true

- name: Upgrade pip
pip:
name: pip
extra_args: --upgrade
become: true

- name: Downloading git repo
git: repo={{repo_url}}
dest={{dest_location}}

- name: installing PIP Packages
pip: requirements={{dest_location}}/requirements.txt
- name: Installing PIP Packages
pip: requirements={{dest_location}}/src/requirements.txt
become: true

- name: Installing docker
shell: curl -sSL get.docker.com | sh
args:
creates: /usr/bin/docker
become: true

- name: Installing docker-compose
pip:
name: docker-compose
state: present
become: true

- name: Placing config file
template:
src=/etc/ansible/openbadge-hub-py/.env
dest=/home/{{user}}/openbadge-hub-py/.env

- name: Placing supervisord file for ip reporting
template:
src=report_ip.conf
dest=/etc/supervisor/conf.d/report_ip.conf
become: true

- name: Placing supervisord file for starting pulling data
template:
src=badge_hub.conf
Expand Down
7 changes: 0 additions & 7 deletions playbooks/report_ip.conf

This file was deleted.

0 comments on commit eaa52ff

Please sign in to comment.