From db9c2b764e65c78dbc2237a468d62c1954354e72 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Mon, 20 Jul 2020 12:29:14 +0300 Subject: [PATCH] Add docker files dockerfile and docker-compose have not been tested. --- README.md | 8 +++++++- docker/docker-compose.yml | 18 +++++++++++++++++ routes/users.js | 9 --------- app.js => web/app.js | 0 {bin => web/bin}/www | 0 .../fetchLabs.js => web/config/creds.js | 0 web/dockerfile | 19 ++++++++++++++++++ {locales => web/locales}/el.json | 0 {locales => web/locales}/en.json | 0 package-lock.json => web/package-lock.json | 2 +- package.json => web/package.json | 7 ++++--- .../annie-spratt-QckxruozjRg-unsplash.jpg | Bin .../markus-spiske-qjnAnF0jIGk-unsplash.jpg | Bin .../thomas-jensen-ISG-rUel0Uw-unsplash.jpg | Bin .../images/yancy-min-842ofHC6MaI-unsplash.jpg | Bin {public => web/public}/javascripts/bs-init.js | 0 web/public/javascripts/fetchLabs.js | 0 .../public}/stylesheets/Footer-Dark.css | 0 .../stylesheets/Navigation-with-Button.css | 0 .../public}/stylesheets/bootstrap.min.css | 0 {routes => web/routes}/index.js | 1 - {views => web/views}/error.ejs | 0 {views => web/views}/index.ejs | 0 23 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 docker/docker-compose.yml delete mode 100755 routes/users.js rename app.js => web/app.js (100%) rename {bin => web/bin}/www (100%) rename public/javascripts/fetchLabs.js => web/config/creds.js (100%) create mode 100644 web/dockerfile rename {locales => web/locales}/el.json (100%) rename {locales => web/locales}/en.json (100%) rename package-lock.json => web/package-lock.json (99%) rename package.json => web/package.json (82%) rename {public => web/public}/images/annie-spratt-QckxruozjRg-unsplash.jpg (100%) rename {public => web/public}/images/markus-spiske-qjnAnF0jIGk-unsplash.jpg (100%) rename {public => web/public}/images/thomas-jensen-ISG-rUel0Uw-unsplash.jpg (100%) rename {public => web/public}/images/yancy-min-842ofHC6MaI-unsplash.jpg (100%) rename {public => web/public}/javascripts/bs-init.js (100%) create mode 100644 web/public/javascripts/fetchLabs.js rename {public => web/public}/stylesheets/Footer-Dark.css (100%) rename {public => web/public}/stylesheets/Navigation-with-Button.css (100%) rename {public => web/public}/stylesheets/bootstrap.min.css (100%) rename {routes => web/routes}/index.js (74%) rename {views => web/views}/error.ejs (100%) rename {views => web/views}/index.ejs (100%) diff --git a/README.md b/README.md index 056b281..5343059 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -swarmlab.io +# *[swarmlab.io](www.docs.swarmlab.io)* + +Swarmlab is a powerful collaboration tool that connects tutors and students in a unique all-in-one environment that gets work done fast and easily. + + + + diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..68265ab --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3.8" +services: + webapp: + build: ../web + dockerfile: dockerfile + image: webapp:latest +deploy: + mode: replicated + replicas: 2 + restart_policy: + condition: on-failure + delay: 10s + max_attempts: 3 + window: 120s + placement: + max_replicas_per_node: 1 + constraints: + - "node.role==manager" diff --git a/routes/users.js b/routes/users.js deleted file mode 100755 index 623e430..0000000 --- a/routes/users.js +++ /dev/null @@ -1,9 +0,0 @@ -var express = require('express'); -var router = express.Router(); - -/* GET users listing. */ -router.get('/', function(req, res, next) { - res.send('respond with a resource'); -}); - -module.exports = router; diff --git a/app.js b/web/app.js similarity index 100% rename from app.js rename to web/app.js diff --git a/bin/www b/web/bin/www similarity index 100% rename from bin/www rename to web/bin/www diff --git a/public/javascripts/fetchLabs.js b/web/config/creds.js similarity index 100% rename from public/javascripts/fetchLabs.js rename to web/config/creds.js diff --git a/web/dockerfile b/web/dockerfile new file mode 100644 index 0000000..8506b70 --- /dev/null +++ b/web/dockerfile @@ -0,0 +1,19 @@ +FROM node:latest + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +# If you are building your code for production +# RUN npm ci --only=production + +# Bundle app source +COPY . . + +EXPOSE 8080 +CMD [ "node", "./bin/www" ] \ No newline at end of file diff --git a/locales/el.json b/web/locales/el.json similarity index 100% rename from locales/el.json rename to web/locales/el.json diff --git a/locales/en.json b/web/locales/en.json similarity index 100% rename from locales/en.json rename to web/locales/en.json diff --git a/package-lock.json b/web/package-lock.json similarity index 99% rename from package-lock.json rename to web/package-lock.json index 4dda700..984fe36 100755 --- a/package-lock.json +++ b/web/package-lock.json @@ -1,6 +1,6 @@ { "name": "swarmlab.io", - "version": "0.0.0", + "version": "0.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/web/package.json similarity index 82% rename from package.json rename to web/package.json index 83bc2f6..14c8629 100755 --- a/package.json +++ b/web/package.json @@ -1,9 +1,10 @@ { "name": "swarmlab.io", - "version": "0.0.0", + "version": "0.1.0", "private": true, "scripts": { - "start": "nodemon ./bin/www" + "start": "node ./bin/www", + "dev": "nodemon ./bin/www" }, "dependencies": { "cookie-parser": "~1.4.4", @@ -18,4 +19,4 @@ "morgan": "~1.9.1", "nodemon": "^2.0.4" } -} \ No newline at end of file +} diff --git a/public/images/annie-spratt-QckxruozjRg-unsplash.jpg b/web/public/images/annie-spratt-QckxruozjRg-unsplash.jpg similarity index 100% rename from public/images/annie-spratt-QckxruozjRg-unsplash.jpg rename to web/public/images/annie-spratt-QckxruozjRg-unsplash.jpg diff --git a/public/images/markus-spiske-qjnAnF0jIGk-unsplash.jpg b/web/public/images/markus-spiske-qjnAnF0jIGk-unsplash.jpg similarity index 100% rename from public/images/markus-spiske-qjnAnF0jIGk-unsplash.jpg rename to web/public/images/markus-spiske-qjnAnF0jIGk-unsplash.jpg diff --git a/public/images/thomas-jensen-ISG-rUel0Uw-unsplash.jpg b/web/public/images/thomas-jensen-ISG-rUel0Uw-unsplash.jpg similarity index 100% rename from public/images/thomas-jensen-ISG-rUel0Uw-unsplash.jpg rename to web/public/images/thomas-jensen-ISG-rUel0Uw-unsplash.jpg diff --git a/public/images/yancy-min-842ofHC6MaI-unsplash.jpg b/web/public/images/yancy-min-842ofHC6MaI-unsplash.jpg similarity index 100% rename from public/images/yancy-min-842ofHC6MaI-unsplash.jpg rename to web/public/images/yancy-min-842ofHC6MaI-unsplash.jpg diff --git a/public/javascripts/bs-init.js b/web/public/javascripts/bs-init.js similarity index 100% rename from public/javascripts/bs-init.js rename to web/public/javascripts/bs-init.js diff --git a/web/public/javascripts/fetchLabs.js b/web/public/javascripts/fetchLabs.js new file mode 100644 index 0000000..e69de29 diff --git a/public/stylesheets/Footer-Dark.css b/web/public/stylesheets/Footer-Dark.css similarity index 100% rename from public/stylesheets/Footer-Dark.css rename to web/public/stylesheets/Footer-Dark.css diff --git a/public/stylesheets/Navigation-with-Button.css b/web/public/stylesheets/Navigation-with-Button.css similarity index 100% rename from public/stylesheets/Navigation-with-Button.css rename to web/public/stylesheets/Navigation-with-Button.css diff --git a/public/stylesheets/bootstrap.min.css b/web/public/stylesheets/bootstrap.min.css similarity index 100% rename from public/stylesheets/bootstrap.min.css rename to web/public/stylesheets/bootstrap.min.css diff --git a/routes/index.js b/web/routes/index.js similarity index 74% rename from routes/index.js rename to web/routes/index.js index 78c700e..f54df01 100755 --- a/routes/index.js +++ b/web/routes/index.js @@ -1,7 +1,6 @@ var express = require('express'); var router = express.Router(); -/* GET home page. */ router.get('/', (req, res, next) => { res.render('index'); }); diff --git a/views/error.ejs b/web/views/error.ejs similarity index 100% rename from views/error.ejs rename to web/views/error.ejs diff --git a/views/index.ejs b/web/views/index.ejs similarity index 100% rename from views/index.ejs rename to web/views/index.ejs