From 305182282b54f61f003478d16e7fcf84c6e6c795 Mon Sep 17 00:00:00 2001 From: Stefan Held Date: Sat, 14 Jul 2018 06:10:37 +0200 Subject: [PATCH] Finalize Docker stuff for: https://github.com/PixelogicDev/FocusBlock/issues/25 --- Nginx/conf.d/app.conf | 2 +- README.md | 5 ++-- Server/.dockerignore | 5 ++++ Server/Dockerfile | 16 ++++++++++ Server/nodemon.json | 6 ++++ docker-compose.yaml | 61 +++++++++++++++++++++++++++++++++++++++ focus-block/.dockerignore | 5 ++++ focus-block/Dockerfile | 13 +++++++++ 8 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 Server/.dockerignore create mode 100644 Server/Dockerfile create mode 100644 Server/nodemon.json create mode 100644 docker-compose.yaml create mode 100644 focus-block/.dockerignore create mode 100644 focus-block/Dockerfile diff --git a/Nginx/conf.d/app.conf b/Nginx/conf.d/app.conf index 03b4ef2..39da689 100644 --- a/Nginx/conf.d/app.conf +++ b/Nginx/conf.d/app.conf @@ -4,7 +4,7 @@ server { access_log off; location / { - proxy_pass http://backend:8080; + proxy_pass http://frontend:8080; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; diff --git a/README.md b/README.md index 0b06c8f..e8f47ff 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,9 @@ FocusBlock uses a Node.js server in order to handle communication between the cl Start by creating a `.env` file that will store these properties: -- `BASE_PATH`=localhost:3000 -- `DB_PATH`=mongodb://localhost:27017/focusblock +- `BASE_PATH`=localhost +- `PORT`=3000 +- `DB_HOST`=localhost:27017 - `DB_NAME`=focusblock ##### Start Server diff --git a/Server/.dockerignore b/Server/.dockerignore new file mode 100644 index 0000000..ecd52c6 --- /dev/null +++ b/Server/.dockerignore @@ -0,0 +1,5 @@ +.git +.gitignore +README.md +docker-compose.yml +node_modules \ No newline at end of file diff --git a/Server/Dockerfile b/Server/Dockerfile new file mode 100644 index 0000000..5122c7d --- /dev/null +++ b/Server/Dockerfile @@ -0,0 +1,16 @@ +FROM node:8-slim + +RUN mkdir /app + +RUN npm install nodemon -g + +WORKDIR /app +COPY . . +#ADD . . + +RUN npm install + + +EXPOSE 3000 + +CMD npm start \ No newline at end of file diff --git a/Server/nodemon.json b/Server/nodemon.json new file mode 100644 index 0000000..f1b04c6 --- /dev/null +++ b/Server/nodemon.json @@ -0,0 +1,6 @@ +{ + "env": { + "NODE_ENV": "development" + }, + "ext": "js json hjs" +} \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..7c316f6 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,61 @@ +version: '3' +services: + nginx: + container_name: focusblock-nginx + image: nginx:latest + #restart: always + ports: + - "80:80" + volumes: + - ./Nginx/conf.d:/etc/nginx/conf.d + links: + - frontend + depends_on: + - frontend + + mongodb: + container_name: focusblock-mongodb + image: mongo:latest + command: mongod --storageEngine=wiredTiger + ports: + - "27017:27017" + volumes: + - ./MongoDB:/data/db + + backend: + container_name: focusblock-backend + build: ./Server + restart: on-failure + environment: + BASE_PATH: localhostxs + DB_HOST: mongodb:27017 + DB_NAME: focusblock + PORT: 3000 + #volumes: + # - ./Server:/app + ports: + - "3000:3000" + links: + - mongodb + depends_on: + - mongodb + + frontend: + container_name: focusblock-frontend + build: "./focus-block" + environment: + #SMTP Username for SMTPJS (From Sengrid) + REACT_APP_SMTP_USERNAME: CHANGE_ME + #SMTP Password for SMTPJS (From Sengrid) + REACT_APP_SMTP_PW: CHANGE_ME_TOO + #The route for your Node Server (ex. http://localhost:8000) + REACT_APP_API_BASE: http://backend:3000 + PORT: 8080 + #volumes: + # - ./focus-block:/app + ports: + - "8080:8080" + links: + - backend + depends_on: + - backend diff --git a/focus-block/.dockerignore b/focus-block/.dockerignore new file mode 100644 index 0000000..ee2bbf0 --- /dev/null +++ b/focus-block/.dockerignore @@ -0,0 +1,5 @@ +.git +../Server/.gitignore +README.md +docker-compose.yml +node_modules \ No newline at end of file diff --git a/focus-block/Dockerfile b/focus-block/Dockerfile new file mode 100644 index 0000000..61583ea --- /dev/null +++ b/focus-block/Dockerfile @@ -0,0 +1,13 @@ +FROM node:8-slim + +RUN mkdir /app +RUN npm install npm-run-all -g + +WORKDIR /app +COPY . . +#ADD . . +RUN npm install + +EXPOSE 8080 + +CMD npm start \ No newline at end of file