From fe89945991b0970c590d9d23c837dea1b524786d Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Tue, 28 Jan 2020 21:39:48 +0100 Subject: [PATCH] Add docker-compose file for local testing. --- backend/.env.development | 2 + backend/server.js | 3 - docker-compose.yml | 94 +++++++++++++++++++++++++++++++ informed.svg | 116 --------------------------------------- install.sh | 34 ------------ uninstall.sh | 1 + 6 files changed, 97 insertions(+), 153 deletions(-) create mode 100644 docker-compose.yml delete mode 100644 informed.svg diff --git a/backend/.env.development b/backend/.env.development index d9884baa47..8e2a2fe4cb 100755 --- a/backend/.env.development +++ b/backend/.env.development @@ -17,3 +17,5 @@ NODE_ENV=development WINDOWMS=216000 MAX=5000 RATE_LIMITING_ENABLED=false +MONGO_URL=mongodb://mongo:27017/fyipedb +REDIS_HOST=redis diff --git a/backend/server.js b/backend/server.js index 8d4657e985..84abb42618 100755 --- a/backend/server.js +++ b/backend/server.js @@ -7,9 +7,6 @@ var redisAdapter = require('socket.io-redis'); var keys = require('./backend/config/keys.js'); var bodyParser = require('body-parser'); var cors = require('cors'); -//var { fork } = require('child_process'); - -//fork('./backend/workers/cronjob.js'); var { NODE_ENV } = process.env; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..9e41e78c0c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,94 @@ +version: "3.7" +services: + + mongo: + image: mongo:3.4 + ports: + - "27017:27017" + volumes: + - mongodata:/data/db + + redis: + image: redis:5.0.7 + ports: + - "6379:6379" + command: redis-server + + backend: + ports: + - "3002:3002" + env_file: ./backend/.env.development + build: ./backend + depends_on: + - mongo + - redis + + accounts: + ports: + - "3003:3003" + build: ./accounts + depends_on: + - backend + + dashboard: + ports: + - "3000:3000" + build: ./dashboard + depends_on: + - backend + + home: + ports: + - "1444:1444" + build: ./home + + status-page: + ports: + - "3006:3006" + build: ./status-page + depends_on: + - backend + - accounts + - dashboard + + admin-dashboard: + ports: + - "3100:3100" + build: ./dashboard + depends_on: + - backend + - accounts + + http-test-server: + ports: + - "3010:3010" + build: ./http-test-server + + probe1: + ports: + - "3019:3019" + build: ./probe + environment: + - PORT=3019 + - SERVER_URL=http://backend:3002 + - PROBE_NAME=Probe 1 + - PROBE_KEY=test-key + depends_on: + - backend + + probe2: + ports: + - "3020:3020" + build: ./probe + environment: + - PORT=3020 + - SERVER_URL=http://backend:3002 + - PROBE_NAME=Probe 2 + - PROBE_KEY=test-key + depends_on: + - backend + +volumes: + mongodata: + + diff --git a/informed.svg b/informed.svg deleted file mode 100644 index 3bc8757d5d..0000000000 --- a/informed.svg +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/install.sh b/install.sh index 10c7ea2710..b411e48cb7 100644 --- a/install.sh +++ b/install.sh @@ -8,43 +8,9 @@ fi sudo chmod +x ./uninstall.sh sudo ./uninstall.sh -sudo docker network create fyipe-network || "Netork already exists." - # Sleep sleep 5s -sudo mkdir /Users/$whoami/mongodb || echo 'Path already exists' - -# Run Dependencies -sudo docker run -v /Users/$whoami/mongodb:/data/db -p 27017:27017 -d mongo:3.4 -sudo docker run --name redis -p 6379:6379 -d redis:5.0.7 redis-server - -# Sleep -sleep 5s - -# Run Backend -sudo docker build -t fyipe-project/backend:latest ./backend -sudo docker run --name backend --net=host -p 3002:3002 --env-file=./backend/.env.development -d fyipe-project/backend:latest #port is not needed because of nethost - -# Run Accounts -sudo docker build -t fyipe-project/accounts:latest ./accounts -sudo docker run --name accounts -p 3003:3003 -d fyipe-project/accounts:latest - -#Run Dashboard -sudo docker build -t fyipe-project/dashboard:latest ./dashboard -sudo docker run --name dashboard -p 3000:3000 -d fyipe-project/dashboard:latest - -# Run home -sudo docker build -t fyipe-project/home:latest ./home -sudo docker run --name home -p 1444:1444 -d fyipe-project/home:latest - -# Run Status Page -sudo docker build -t fyipe-project/status-page:latest ./status-page -sudo docker run --name status-page -p 3006:3006 -d fyipe-project/status-page:latest - -# Run Admin Dashboard -sudo docker build -t fyipe-project/admin-dashboard:latest ./admin-dashboard -sudo docker run --name admin-dashboard -p 3100:3100 -d fyipe-project/admin-dashboard:latestcd # Run Probes 1 sudo docker build -t fyipe-project/probe:latest ./probe diff --git a/uninstall.sh b/uninstall.sh index b95ca86a87..3a49113e1a 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,4 +1,5 @@ echo "REMOVING EXISTING CONTAINERS..." +sudo docker-compose down sudo docker stop $(sudo docker ps -aq) || echo 'No docker containers' sudo docker rm $(sudo docker ps -aq) || echo 'No docker containers' echo "EXISTING CONTAINERS REMOVED." \ No newline at end of file