diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..f7d401c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,34 @@ +version: '2' +services: + mongodb: + image: mongo + restart: always + container_name: mongocrypto + environment: + - MONGO_INITDB_ROOT_USERNAME=crypto-admin + - MONGO_INITDB_ROOT_PASSWORD=crypto-admin + - MONGO_DATA_DIR=/data/db + - MONGO_LOG_DIR=/dev/null + volumes: + - ./mongo.docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d + - ./data/db:/data/db + ports: + - 27017:27017 + command: '--auth' + + hippo: + depends_on: + - mongodb + image: tsavo/hippo:latest + restart: always + working_dir: /app + environment: + - HIPPO_DB_URL=mongocrypto + - HIPPO_DB_NAME=cryptomarket + - HIPPO_DB_USERNAME=crypto-rw + - HIPPO_DB_PASSWORD=crypto-rw + volumes: + - .:/app + command: mvn install exec:exec + links: + - mongodb:mongocrypto diff --git a/mongo.docker-entrypoint-initdb.d/init-db.js b/mongo.docker-entrypoint-initdb.d/init-db.js new file mode 100644 index 0000000..e647955 --- /dev/null +++ b/mongo.docker-entrypoint-initdb.d/init-db.js @@ -0,0 +1,5 @@ +db = db.getSiblingDB('admin'); +db.auth( { user: 'crypto-admin', pwd: 'crypto-admin' }); + +db = db.getSiblingDB('cryptomarket'); +db.createUser({ user: 'crypto-rw', pwd: 'crypto-rw', roles: [ { role: "dbOwner", db: "cryptomarket" } ] }); diff --git a/start.sh b/start.sh index cf9fe41..2a67cfd 100755 --- a/start.sh +++ b/start.sh @@ -1,3 +1,2 @@ #!/bin/bash -docker run -d -v $PWD:/app -w /app tsavo/hippo:latest mvn install exec:exec - +docker-compose up -d