Skip to content

Commit

Permalink
Improve Dockerfile, compose commands, compose.sh
Browse files Browse the repository at this point in the history
 - Require volume and set WORKDIR on Dockerfile (saves having to `cd`
   before all the commands in `compose.yml`
 - Use image named netrunner-node rather than build on each
   `docker-compose up`
 - Add flag to `./compose.sh` to build netrunner-node image from
   Dockerfile
 - Move environment variables defined in service commands into compose
   `environment:` fields
 - Separate npm-install service from fetch service (which pulls card
   data)
 - Rename working directory in containers from `/workdir` to `/netrunner`
  • Loading branch information
strongoose committed Mar 5, 2017
1 parent 4b1b84e commit 84f11f2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 19 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
FROM node:latest

RUN apt-get update && apt-get install -y libzmq3-dev

VOLUME /netrunner

WORKDIR /netrunner
25 changes: 25 additions & 0 deletions compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

set -e

usage () {
cat<<EOF
Usage: $0 [-b]
-b build netrunner-node image
EOF
}

while getopts ':b' o; do
case "${o}" in
b)
BUILD=true
;;
*)
usage
;;
esac
done

if [[ -n ${BUILD} ]]; then
docker build -t netrunner-node .
fi

docker-compose up npm-install

docker-compose up npm

docker-compose up netrunner coffee stylus lein
42 changes: 23 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
version: '2'
services:

npm:
build: .
npm-install:
image: netrunner-node
volumes:
- .:/workdir
- .:/netrunner
command: |
sh -c "npm install
./node_modules/.bin/bower --allow-root install"
fetch:
image: netrunner-node
volumes:
- .:/netrunner
links:
- mongo
command: |
sh -c "cd /workdir
npm install
./node_modules/.bin/bower --allow-root install
OPENSHIFT_MONGODB_DB_HOST=mongo npm run fetch"
environment:
OPENSHIFT_MONGODB_DB_HOST: mongo
command: npm run fetch

mongo:
image: mongo:latest
Expand Down Expand Up @@ -41,23 +47,21 @@ services:
lein run"
stylus:
build: .
image: netrunner-node
volumes:
- .:/workdir
command: |
sh -c "cd /workdir
./node_modules/.bin/stylus -w src/css -o resources/public/css/"
- .:/netrunner
command: ./node_modules/.bin/stylus -w src/css -o resources/public/css/

coffee:
build: .
image: netrunner-node
volumes:
- .:/workdir
- .:/netrunner
ports:
- 1042:1042
links:
- mongo
- netrunner
command: |
sh -c "apt-get update && apt-get install -y libzmq3-dev
cd /workdir
MONGO_URL=mongodb://mongo:27017/netrunner CLOJURE_HOST=netrunner ./node_modules/.bin/coffee server.coffee"
environment:
MONGO_URL: mongodb://mongo:27017/netrunner
CLOJURE_HOST: netrunner
command: ./node_modules/.bin/coffee server.coffee

0 comments on commit 84f11f2

Please sign in to comment.