diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 0000000..6ade00f --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,17 @@ +ember: &defaults + image: danlynn/ember-cli + volumes: + - .:/myapp + command: server --watcher polling + ports: + - "4200:4200" + - "35729:35729" + +npm: + <<: *defaults + entrypoint: ['/usr/local/bin/npm'] + +bower: + <<: *defaults + entrypoint: ['/usr/local/bin/bower', '--allow-root'] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..97e2e63 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +nginx: + image: nginx + volumes: + - nginx.default.conf:/etc/nginx/conf.d/default.conf + links: + - orion + - ember + ports: + - "80:80" + +ember: + image: danlynn/ember-cli + volumes: + - .:/myapp + command: server --watcher polling + +mongo: + image: mongo:2.6 + command: --smallfiles --nojournal --dbpath=/tmp/ + +orion: + image: fiware/orion + links: + - mongo + command: -dbhost mongo + +#playback: +# image: playback +# volumes: +# - /share:/share +# links: +# - orion +# command: orion:1026 + + diff --git a/docker.sh b/docker.sh new file mode 100755 index 0000000..8d8908e --- /dev/null +++ b/docker.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Note that this will automagically be ran if you have rvm installed. +# This shell file sets up the following aliases whenever you cd into +# the current directory tree: +# +# + ember +# + npm +# + bower +# +# If rvm is not installed then you can simply run: +# . setup.sh +# +# Note that these aliases revert back to executing the system version +# of each command whenever you exit the current project dir tree. + +PREV_ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +function npm() { + if [[ $PWD/ = $PREV_ROOT_DIR/* ]]; then + # echo "docker-compose -f $PREV_ROOT_DIR/docker-compose-dev.yml run --rm npm $@" + docker-compose -f $PREV_ROOT_DIR/docker-compose-dev.yml run --rm npm $@ + else + # echo "`which npm` $@" + `which npm` $@ + fi +} + +function bower() { + if [[ $PWD/ = $PREV_ROOT_DIR/* ]]; then + # echo "docker-compose -f $PREV_ROOT_DIR/docker-compose-dev.yml run --rm bower $@" + docker-compose -f $PREV_ROOT_DIR/docker-compose-dev.yml run --rm bower $@ + else + # echo "`which bower` $@" + `which bower` $@ + fi +} + +function ember() { + if [[ $PWD/ = $PREV_ROOT_DIR/* ]]; then + # echo "docker-compose -f $PREV_ROOT_DIR/docker-compose-dev.yml run --rm ember $@" + docker-compose -f $PREV_ROOT_DIR/docker-compose-dev.yml run --rm ember $@ + else + # echo "`which ember` $@" + `which ember` $@ + fi +} + +# manual method of aliasing that persists when outside of current dir (BAD) +# alias npm='docker-compose -f docker-compose-dev.yml run --rm npm' +# alias bower='docker-compose -f docker-compose-dev.yml run --rm bower' +# alias ember='docker-compose -f docker-compose-dev.yml run --rm ember' + +# echo 'Configured npm, bower, and ember for current project' diff --git a/nginx.default.conf b/nginx.default.conf new file mode 100644 index 0000000..52c4545 --- /dev/null +++ b/nginx.default.conf @@ -0,0 +1,49 @@ +server { + listen 80 default_server; + server_name labmashup; + + # proxy for ember-cli + location ^~ /frontend/ { + proxy_redirect off; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_pass http://ember:4200/frontend/; + } + + # proxy for orion context broker + location ^~ /api/ { + proxy_redirect off; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + if ($request_method = 'OPTIONS') { + add_header Access-Control-Allow-Origin '$http_origin' always; + add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE' always; + add_header Access-Control-Allow-Credentials 'true' always; + add_header Access-Control-Allow-Headers 'Origin,Content-Type,Accept' always; + add_header Content-Length 0; + add_header Content-Type text/plain; + + return 204; + } + + # rewrite url to exclude /api on context broker side + rewrite ^/api/?(.*) /$1 break; + + add_header Access-Control-Allow-Origin '*' always; + add_header Access-Control-Allow-Credentials 'true' always; + + proxy_pass http://orion:1026; + } + + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +}