Skip to content

Commit

Permalink
Add docker-compose for easier provisioning
Browse files Browse the repository at this point in the history
Add esdata dir to gitignore
  • Loading branch information
robbyoconnor committed Feb 28, 2016
1 parent 4ca141e commit 94dfc65
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
irc:channel=#openmrstest
elasticsearch:host=http://elasticsearch:9200
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
config.json
node_modules
logs
npm-debug.log
npm-debug.log
esdata
54 changes: 46 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
# Record Scrum notes from the #openmrs IRC channel

You may set settings such as the channel and the elasticsearch host [.env](.env) in this working directory, or optionally in `config.json`. A sample `.env` file is provided.
## Before building

npm install -g mocha

## Development

You need to start the elasticsearch prior to spinning up the web container. This guide supports both normal and [docker-compose][] use-cases.

### ES (for a dev environment on OSX)

$ docker run --name es -d -p 9200:9200 -p 9300:9300 elasticsearch -Des.network.bindHost=0.0.0.0
``` shell
$ docker run --name es -d -p 9200:9200 -p 9300:9300 elasticsearch -Des.network.bindHost=0.0.0.0
```

Using [docker-compose][]:

``` shell
$ docker-composeup -d elasticsearch
```


## Run just the listener (without the webapp)

$ node index --elasticsearch.host http://192.168.99.100:9200
Expand All @@ -30,28 +41,55 @@ If you do not have elasticsearch running on localhost:9200, then create a "confi
Then

$ npm start

And see the webapp running on http://localhost:3000

### Testing the docker build locally

$ docker run --name web -d -p 3000:3000 --link es:es -e "elasticsearch:host=http://es:9200" -e "irc:channel=#openmrstest" djazayeri/openmrs-scrumbot:1.0
``` shell
$ docker run --name web -d -p 3000:3000 --link es:es -e "elasticsearch:host=http://es:9200" -e "irc:channel=#openmrstest" djazayeri/openmrs-scrumbot:1.0
```
Or using [docker-compose][] –- this assumes you have started the elasticsearch container.

``` shell
$ docker-compose run elasticsearch web
```

## Prod

Note: this approach uses LINK networking, which will eventually be deprecated in Docker.

### ES for prod on a Digital Ocean one-click app Docker box (don't expose ElasticSearch to the outside world, since it isn't secured)

$ docker run -d --restart="unless-stopped" --name es -v "$PWD/esdata":/usr/share/elasticsearch/data -p 127.0.0.1:9200:9200 elasticsearch

``` shell
$ docker run -d --restart="unless-stopped" --name es -v "$PWD/esdata":/usr/share/elasticsearch/data -p 127.0.0.1:9200:9200 elasticsearch
```
or using [docker-compose][]

``` shell
$ docker-compose -f docker-compose.yml -f docker-compose-prod.yml up -d elasticsearch web
```



### dockerhub does builds automatically

Whenever you commit code to this repository it is automatically built as djazayeri/openmrs-contrib-scrumbot:latest
Whenever you commit code to this repository it is automatically built as djazayeri/openmrs-contrib-scrumbot:latest

### run webapp+bot on docker on Digital Ocean

// this is automated as ./update-web

``` shell
$ docker pull djazayeri/openmrs-contrib-scrumbot:latest
$ docker rm web
$ docker run -d -p 80:3000 --name web --link es:es -e "elasticsearch:host=http://es:9200" djazayeri/openmrs-contrib-scrumbot:latest
```

You may also use [docker-compose][] to handle this:

``` shell
$ docker-compose -f docker-compose.yml -f docker-compose-prod.yml up -d elasticsearch web
```

[docker-compose]: https://docs.docker.com/compose/
4 changes: 4 additions & 0 deletions docker-compose-overrides.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
elasticsearch:
ports:
– "9200:9200"
- "9300:9300"
4 changes: 4 additions & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
elasticsearch:
ports:
- "127.0.0.1:9200:9200"
- "127.0.0.1:9300:9300"
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
web:
build: .
links:
- elasticsearch
env_file: ./.env
elasticsearch:
image: elasticsearch:latest
command: elasticsearch -Des.network.bindHost=0.0.0.0
volumes:
- "./esdata:/usr/share/elasticsearch/data"

0 comments on commit 94dfc65

Please sign in to comment.