diff --git a/Dockerfile b/Dockerfile index 1f71686e5..19764808e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,11 @@ -FROM node:0.10-slim +# Change latest to your desired node version (https://hub.docker.com/r/library/node/tags/) +FROM node:7.10 +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app -COPY ./package.json /src/package.json -RUN cd /src && npm install -COPY ./ /src -RUN npm install -g mocha -RUN npm install -g istanbul -RUN npm install -g gulp +COPY package.json /usr/src/app/ +RUN npm install +COPY . /usr/src/app -WORKDIR /src -#ENV DEBUG=* - -EXPOSE 8080 5222 - -CMD ["npm", "start"] +CMD [ "npm", "start" ] diff --git a/Dockerfile.latest b/Dockerfile.latest new file mode 100644 index 000000000..44a681c47 --- /dev/null +++ b/Dockerfile.latest @@ -0,0 +1,11 @@ +# Change latest to your desired node version (https://hub.docker.com/r/library/node/tags/) +FROM node:latest + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY package.json /usr/src/app/ +RUN npm install --silent +COPY . /usr/src/app + +CMD [ "npm", "start" ] diff --git a/Dockerfile_prod b/Dockerfile_prod new file mode 100644 index 000000000..49e3ae6a7 --- /dev/null +++ b/Dockerfile_prod @@ -0,0 +1,12 @@ +FROM node:0.10-slim + +COPY ./package.json /src/package.json +RUN cd /src && npm install +COPY ./ /src + +WORKDIR /src +#ENV DEBUG=* + + +CMD ["npm", "start"] + diff --git a/README.md b/README.md index 8e485467e..1d05e865e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,10 @@ +Build status: [![Codefresh build status]( https://g.codefresh.io/api/badges/build?repoOwner=containers101&repoName=demochat&branch=master&pipelineName=demochatdfdf&accountName=Razielt77_github&type=cf-1)]( https://g.codefresh.io/repositories/containers101/demochat/builds?filter=trigger:build;branch:master;service:58543cb490a3f40100db408f~demochatdfdf) +Demo for Axway ![Let's Chat Greylock](http://i.imgur.com/0a3l5VF.png) -#test1 -#test2 ![Screenshot](http://i.imgur.com/C4uMD67.png) -Test Test A self-hosted chat app for small teams or big Gal by [Security Compass][seccom]. -[![Build Status](https://travis-ci.org/sdelements/lets-chat.svg?branch=master)](https://travis-ci.org/sdelements/lets-chat) -[![Dependency Status](https://david-dm.org/sdelements/lets-chat.svg)](https://david-dm.org/sdelements/lets-chat) -[![devDependency Status](https://david-dm.org/sdelements/lets-chat/dev-status.svg)](https://david-dm.org/sdelements/lets-chat#info=devDependencies) + ## Features and Stuff @@ -91,3 +88,158 @@ Released under [the MIT license][license]. [install-docker]: https://registry.hub.docker.com/u/sdelements/lets-chat/ [install-heroku]: https://github.com/sdelements/lets-chat/wiki/Heroku [install-vagrant]: https://github.com/sdelements/lets-chat/wiki/Vagrant + + + + + +![Let's Chat Greylock](https://codefresh.io/wp-content/uploads/2017/03/lets-chat.png) + + +Use this tutorial to familiarize yourself with codefresh.yml file and Codefresh functionality. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/11.png) + + +This tutorial is based on Let’s Chat [app]. + +https://github.com/containers101/demochat + +### Let’s Chat is self-hosted chat app for small teams or big + +This tutorial will walk you through the process of adding the following : + + +* Build step - that will build Docker image for your Let’s Chat app + +* Push to registry step - that will push your image to Docker Hub + +* Unit Test step - A freestyle step that runs the unit test of the demo chat after the build + +* Composition step - This step will create and launch a composition. + +So, the first thing you need to do is : + +## Fork our repo + +Enter the following link and fork Let’s Chat app!: ```https://github.com/containers101/demochat``` + + +## Add a service +Now enter Codefresh and add your Let’s Chat app as a Codefresh service. + +Click on ___Add Repository___ + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/add-repo.png) + + +Now add your forked demochat repo. You can search for it by typing "demochat" to search. You can also Add by URL here. + +Also, choose the branch for your first build (in this case ```master```) + +When you finish press ___Next___. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/select-repo2.png) + + +Select how you would like to setup your repository. In this case, our repo has a ___Dockerfile___, so we'll select the middle option. + + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/15.png) + +By default, Codefresh searches for your Dockerfile at the root level of your repository, by the name "Dockerfile". The demo-chat example includes a Dockerfile in the root level. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/16.png) + + +Review your Dockerfile, and click ___Create___ to add your repository. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/17.png) + +Clicking on ___Build___ button will trigger a regular build. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/18.png) + +Great, you are running your build for the first time! + +## Push your image to Docker registry +In Codefresh the build images will be automatically pushed to Codefresh registry and there’s no need to specify the [Codefresh Docker Registry](https://docs.codefresh.io/v1.0/docs/codefresh-registry) for the block __Push to Docker Registry__ in the pipeline of repository and you can just skip this step. + +Click on ___Repositories___, and then click on the ___Pipelines___ gear. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/19.png) + +Scroll down to ___Workflow___, and you will see a ___Push to Docker___ button. If you have set up your credentials, click ___Save___ at the bottom of the screen. Otherwise- click on the ___integration page___ link. + +Write your User/Password info, and click ___Save___ to connect. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/20.png) + + +## Unit test your image +Let's head over to ___Piplines___ again. +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/19.png) + +Scroll down to Workflow under ___Build and Unit Test___ + +We'll type in ```echo $(date)``` in the Unit Test Script area. This will print the date, and we'll be able to see our test in action. + +Let's click ___Save___, and ___Build___ to see it in action. + +Great- the date has been printed! + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/22.png) + + +Now let's add a full composition that also contains mongo db. + + +## Add composition + +Our Let's Chat app needs mongo in order to work, so let's add it! + +You can read more about compositions in our docs, but we will also walk through the process here : +https://docs.codefresh.io/docs/create-composition + + +Click the ___Composition___ view icon in the left pane, and click the ___Add Composition___. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/1.png) + +Choose a name for your composition + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/2.png) + +We are going to build our comp from scrath, so click ___Empty Composition___ + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/04/empty_comp.png) + +Now we will click ___Add Service___ and add demochat, the port (50000), and mongo. +Everything looks good here- so let's go ahead and launch by clicking the rocket ship... + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/04/savelaunch_final.png) + + +Once it has completed, a link to our app will be displayed. Let's click it to see if it worked. + + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/04/completed_in.png) + +Success! We have successfully launched a composition. + +![Screenshot](https://codefresh.io/wp-content/uploads/2017/03/10.png) + + + + + + +[app]: https://github.com/containers101/demochat + +## About Containers 101 + +[Containers 101](https://www.meetup.com/Containers-101-meetup/) is online/offline meetup group based in Mountain View that provides guides and helps developers work with Containers. Created by [Codefresh](https://codefresh.io/) which provides environments for every commit, Docker CI and CD, and an embedded registry. + +[Join Containers 101](https://www.meetup.com/Containers-101-meetup/) +Learn more about [Codefresh](https://codefresh.io/) + diff --git a/annotation.yml b/annotation.yml new file mode 100644 index 000000000..1d8ce0ebc --- /dev/null +++ b/annotation.yml @@ -0,0 +1,46 @@ +version: '1.0' +steps: + BuildingDockerImage: + title: Building Docker Image + type: build + image_name: containers101/demochat + working_directory: ./ + dockerfile: Dockerfile + metadata: # Declare the metadata attribute + set: # Specify the set operation + - Unit_Test: true + - API_Test: true + - Ave_Res_Time: 2 msec + - Packet_Loss: 0 + - Security: true + RunningUnitTests: + title: Running Unit Tests + type: composition + composition: 5959cfa8e82afd0001bb2f1c + composition_candidates: + demochat: + image: '${{BuildingDockerImage}}' + entrypoint: sh /codefresh/volume/cf-generated/unit_test_script + volumes: + - '${{CF_VOLUME_NAME}}:/codefresh/volume' + add_flow_volume_to_composition: true + create_file: + path: /codefresh/volume/cf-generated + name: unit_test_script + content: npm test + on_success: + metadata: + set: + - '${{BuildingDockerImage.imageId}}': + - CF_QUALITY: true +# - Unit Test: true +# - API Test: true +# - Performance: Average Response Time 2msec +# - Performance: 0 Packet Loss +# - Security: true + on_fail: + metadata: + set: + - '${{BuildingDockerImage.imageId}}': + - CF_QUALITY: false + diff --git a/app.js b/app.js index 0893b113f..9b139b5e2 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ // -// Let's Chat +// Let's Chat main file // 'use strict'; @@ -8,40 +8,40 @@ process.title = 'letschat'; require('colors'); -var _ = require('lodash'), - path = require('path'), - fs = require('fs'), - express = require('express.oi'), - i18n = require('i18n'), - bodyParser = require('body-parser'), +var _ = require('lodash'), + path = require('path'), + fs = require('fs'), + express = require('express.oi'), + i18n = require('i18n'), + bodyParser = require('body-parser'), cookieParser = require('cookie-parser'), - compression = require('compression'), - helmet = require('helmet'), - http = require('http'), - nunjucks = require('nunjucks'), - mongoose = require('mongoose'), - migroose = require('./migroose'), + compression = require('compression'), + helmet = require('helmet'), + http = require('http'), + nunjucks = require('nunjucks'), + mongoose = require('mongoose'), + migroose = require('./migroose'), connectMongo = require('connect-mongo'), - all = require('require-tree'), - psjon = require('./package.json'), - settings = require('./app/config'), - auth = require('./app/auth/index'), - core = require('./app/core/index'); - -var MongoStore = connectMongo(express.session), - httpEnabled = settings.http && settings.http.enable, + all = require('require-tree'), + psjon = require('./package.json'), + settings = require('./app/config'), + auth = require('./app/auth/index'), + core = require('./app/core/index'); + +var MongoStore = connectMongo(express.session), + httpEnabled = settings.http && settings.http.enable, httpsEnabled = settings.https && settings.https.enable, - models = all(path.resolve('./app/models')), - middlewares = all(path.resolve('./app/middlewares')), - controllers = all(path.resolve('./app/controllers')), + models = all(path.resolve('./app/models')), + middlewares = all(path.resolve('./app/middlewares')), + controllers = all(path.resolve('./app/controllers')), app; // // express.oi Setup // if (httpsEnabled) { - app = express().https({ - key: fs.readFileSync(settings.https.key), + app = express().https({ + key: fs.readFileSync(settings.https.key), cert: fs.readFileSync(settings.https.cert) }).io(); } else { @@ -56,20 +56,20 @@ if (settings.env === 'production') { // Session var sessionStore = new MongoStore({ - url: settings.database.uri, + url: settings.database.uri, autoReconnect: true }); // Session var session = { - key: 'connect.sid', - secret: settings.secrets.cookie, - store: sessionStore, - cookie: { secure: httpsEnabled }, - resave: false, + key: 'connect.sid', + secret: settings.secrets.cookie, + store: sessionStore, + cookie: { secure: httpsEnabled }, + resave: false, saveUninitialized: true }; - +debugger; // Set compression before any routes app.use(compression({ threshold: 512 })); @@ -85,32 +85,32 @@ app.use(helmet.ieNoOpen()); app.use(helmet.noSniff()); app.use(helmet.xssFilter()); app.use(helmet.hsts({ - maxAge: 31536000, + maxAge: 31536000, includeSubdomains: true, - force: httpsEnabled, - preload: true + force: httpsEnabled, + preload: true })); app.use(helmet.contentSecurityPolicy({ defaultSrc: ['\'none\''], connectSrc: ['*'], - scriptSrc: ['\'self\'', '\'unsafe-eval\''], - styleSrc: ['\'self\'', 'fonts.googleapis.com', '\'unsafe-inline\''], - fontSrc: ['\'self\'', 'fonts.gstatic.com'], - mediaSrc: ['\'self\''], - objectSrc: ['\'self\''], - imgSrc: ['*'] + scriptSrc: ['\'self\'', '\'unsafe-eval\''], + styleSrc: ['\'self\'', 'fonts.googleapis.com', '\'unsafe-inline\''], + fontSrc: ['\'self\'', 'fonts.gstatic.com'], + mediaSrc: ['\'self\''], + objectSrc: ['\'self\''], + imgSrc: ['*'] })); var bundles = {}; app.use(require('connect-assets')({ - paths: [ + paths: [ 'media/js', 'media/less' ], - helperContext: bundles, - build: settings.env === 'production', + helperContext: bundles, + build: settings.env === 'production', fingerprinting: settings.env === 'production', - servePath: 'media/dist' + servePath: 'media/dist' })); // Public @@ -121,24 +121,24 @@ app.use('/media', express.static(__dirname + '/media', { // Templates var nun = nunjucks.configure('templates', { autoescape: true, - express: app, - tags: { - blockStart: '<%', - blockEnd: '%>', + express: app, + tags: { + blockStart: '<%', + blockEnd: '%>', variableStart: '<$', - variableEnd: '$>', - commentStart: '<#', - commentEnd: '#>' + variableEnd: '$>', + commentStart: '<#', + commentEnd: '#>' } }); function wrapBundler(func) { // This method ensures all assets paths start with "./" // Making them relative, and not absolute - return function() { + return function () { return func.apply(func, arguments) - .replace(/href="\//g, 'href="./') - .replace(/src="\//g, 'src="./'); + .replace(/href="\//g, 'href="./') + .replace(/src="\//g, 'src="./'); }; } @@ -148,7 +148,7 @@ nun.addGlobal('text_search', false); // i18n i18n.configure({ - directory: __dirname + '/locales', + directory: __dirname + '/locales', defaultLocale: settings.i18n && settings.i18n.locale || 'en' }); app.use(i18n.init); @@ -160,7 +160,7 @@ app.use(bodyParser.urlencoded({ })); // IE header -app.use(function(req, res, next) { +app.use(function (req, res, next) { res.setHeader('X-UA-Compatible', 'IE=Edge,chrome=1'); next(); }); @@ -168,13 +168,13 @@ app.use(function(req, res, next) { // // Controllers // -_.each(controllers, function(controller) { +_.each(controllers, function (controller) { controller.apply({ - app: app, - core: core, - settings: settings, + app: app, + core: core, + settings: settings, middlewares: middlewares, - models: models, + models: models, controllers: controllers }); }); @@ -183,13 +183,7 @@ _.each(controllers, function(controller) { // Mongo // -mongoose.connection.on('error', function (err) { - throw new Error(err); -}); -mongoose.connection.on('disconnected', function() { - throw new Error('Could not connect to database'); -}); // // Go Time @@ -197,17 +191,16 @@ mongoose.connection.on('disconnected', function() { function startApp() { var port = httpsEnabled && settings.https.port || - httpEnabled && settings.http.port; + httpEnabled && settings.http.port; var host = httpsEnabled && settings.https.host || - httpEnabled && settings.http.host || '0.0.0.0'; - + httpEnabled && settings.http.host || '0.0.0.0'; if (httpsEnabled && httpEnabled) { // Create an HTTP -> HTTPS redirect server var redirectServer = express(); - redirectServer.get('*', function(req, res) { + redirectServer.get('*', function (req, res) { var urlPort = port === 80 ? '' : ':' + port; res.redirect('https://' + req.hostname + urlPort + req.path); }); @@ -247,11 +240,11 @@ function checkForMongoTextSearch() { return; } - if(version[0] < 2) { + if (version[0] < 2) { return; } - if(version[0] === '2' && version[1] < 6) { + if (version[0] === '2' && version[1] < 6) { return; } @@ -259,19 +252,22 @@ function checkForMongoTextSearch() { }); } -mongoose.connect(settings.database.uri, function(err) { - if (err) { - throw err; - } +var connectionTries = 0; + + +function handleMongoConnectionState(err) { + - checkForMongoTextSearch(); + checkForMongoTextSearch(); + + migroose.needsMigration(function (err, migrationRequired) { - migroose.needsMigration(function(err, migrationRequired) { if (err) { console.error(err); } else if (migrationRequired) { + console.log('Database migration required'.red); console.log('Ensure you backup your database first.'); console.log(''); @@ -282,6 +278,77 @@ mongoose.connect(settings.database.uri, function(err) { return process.exit(); } + console.log('starting app'); startApp(); }); + +} + +const Kefir = require('kefir'); +const interval = 2000; +const Promise = require('bluebird'); +const retry = require('bluebird-retry') +const MongoClient = require('mongodb').MongoClient; +const chalk = require('chalk'); +const debug = require('debug')('app'); + +function tryConnect(callback) { + + console.log(chalk.green('Connecting to database...')); + console.log(chalk.green(new Date())); + console.log(chalk.green(`connection is ${settings.database.uri}`)); + + let p, wrapper = {} + +try{ + + p= MongoClient.connect(settings.database.uri, + {connectTimeoutMS:3000, reconnectTries:1, promiseLibrary:Promise}); + console.log('!!'); + + wrapper = new Promise((resolve, reject)=>{ + p.then(resolve, reject); + }); + + mongoose.connection.on('error', function (err) { + console.log(chalk.red(`connection on error ${err}`)); + callback(err); + }); + + mongoose.connection.on('disconnected', function (err) { + console.log(`disconnected from database error : ${err}`); + callback("error"); + }); +}catch(e){ + console.log(e + exception); + return Promise.reject(); +} +process.on('uncaughtException', function (err) { + debug('uncaughtException: probably due to ' + err); +}) + +console.log(chalk.green('connection in progress')); +p.then(()=>{ + chalk.green('promise resolved '); +},()=>{ + chalk.green('promise rejected '); +}) +return p; + +} +let checkTimeout = ()=>{ + console.log('check timeout'); + return new Promise((resolve, reject)=>{ + setTimeout(1000, ()=>{ + console.log('rejected') + return reject(); + }) + }) +} + + let p = retry(tryConnect, { max_tries: 5, interval: 4000,timeout:30000 }) + .then(handleMongoConnectionState,()=>{ + console.log(chalk.red('we coudnt connect to DB check if its up')); + process.exit(); + }); diff --git a/app/config.js b/app/config.js index 1f2c7b009..876135141 100644 --- a/app/config.js +++ b/app/config.js @@ -165,6 +165,9 @@ var pipeline = [ if (process.env.MONGO_DOCKER) { context.result.database.uri = process.env.MONGO_DOCKER; } + if (process.env.MONGO_HELM) { + context.result.database.uri = "mongodb://" + process.env.MONGO_HELM + ":27017/hp_mongo"; + } }, function openShift(context) { diff --git a/app/tests/mongo.unit.spec.js b/app/tests/mongo.unit.spec.js index 1a0f4c8ed..ac9e00204 100644 --- a/app/tests/mongo.unit.spec.js +++ b/app/tests/mongo.unit.spec.js @@ -1,5 +1,6 @@ var debug = require('debug')('model->test'); var mongoose = require('mongoose'); +const MongoClient = require('mongodb').MongoClient; var TestSchema = new mongoose.Schema({ @@ -12,14 +13,34 @@ var TestSchema = new mongoose.Schema({ var Entity = mongoose.model('Test1', TestSchema); var enitytToSave = new Entity({testField:'test1123232'}); var dbRemote = 'mongodb://admin:hpadmin@ds037415.mongolab.com:37415/hp_mongo'; -var db_local = 'mongodb://192.168.99.100:27017/hp_mongo'; -var db_docker = 'mongodb://mongo:27017/hp_mongo'; +var db_local = 'mongodb://192.168.99.101:27017/hp_mongo'; +var db_docker = 'mongodb://mongo:27017'; describe('sanity tests', function(done){ - +let skip = false; +beforeEach((done)=>{ + //if (process.env.MONGO_TESTS) + done(); + //else{ + //console.log('skipping running tests, make sure MONGO_TESTS env is confugured') + //skip = true; + //done(); + //} +}) +it('test only connection', (done)=>{ + if (skip) return done(); + console.log('test only connection'); + let settings = require('../config'); + MongoClient.connect(db_docker, function(err, db) { + //assert.equal(null, err); + console.log("Connected correctly to server"); + done(err); + db.close(); +}) +}).timeout(5000); it('test mongo connection' , function(done){ - - mongoose.connect(dbRemote, function(err) { + if (skip) return done(); + mongoose.connect(db_docker, function(err) { if (err) { console.log(err); @@ -42,16 +63,4 @@ it('test mongo connection' , function(done){ }); }); -}); - - -/*Object.keys(user).forEach(function(key) { - debug('key:' + key); - userToSave.set(key, user[key]); -});*/ - -/* User.findByToken(username, function(err, user) { - if (err) { return done(err); } - if (!user) { return done(null, false); } - return done(null, user); -});*/ +}).timeout(5000); diff --git a/codefresh.yml b/codefresh.yml new file mode 100644 index 000000000..af855dbf3 --- /dev/null +++ b/codefresh.yml @@ -0,0 +1,24 @@ +version: '1.0' +steps: + build_step: + title: Build + type: build + dockerfile: Dockerfile + image_name: containers101/demochat + tag: '${{CF_BRANCH}}' + + deploy_to_kubernetes: + image: codefresh/cf-deploy-kubernetes + tag: latest + working_directory: ${{main_clone}} + commands: + - /cf-deploy-kubernetes deployment.yml + environment: + - KUBERNETES_USER=${{KUBERNETES_USER}} + - KUBERNETES_PASSWORD=${{KUBERNETES_PASSWORD}} + - KUBERNETES_SERVER=${{KUBERNETES_SERVER}} + - DOCKER_IMAGE_TAG=${{CF_BRANCH}} + when: + condition: + all: + deploy_to_kubernetes: '"${{DEPLOY_KUBERNETES}}" == "true"' diff --git a/deploy/kube-app.yml b/deploy/kube-app.yml new file mode 100644 index 000000000..910d371be --- /dev/null +++ b/deploy/kube-app.yml @@ -0,0 +1,24 @@ +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: app + labels: + service: app +spec: + replicas: 2 + template: + metadata: + annotations: + forceRedeployUniqId: "N/A" + labels: + service: app + spec: + containers: + - image: containers101/demochat:master + name: app + imagePullPolicy: Always + ports: + - containerPort: 5000 + protocol: TCP + diff --git a/deploy/kube-ingress.yml b/deploy/kube-ingress.yml new file mode 100644 index 000000000..08c09b016 --- /dev/null +++ b/deploy/kube-ingress.yml @@ -0,0 +1,25 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: app + name: app +spec: + type: NodePort + ports: + - name: "http" + port: 80 + protocol: TCP + targetPort: 5000 + selector: + service: app +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: demochat-ingress +spec: + backend: + serviceName: app + servicePort: 80 diff --git a/deploy/kube-mongo.yml b/deploy/kube-mongo.yml new file mode 100644 index 000000000..c3e589cd9 --- /dev/null +++ b/deploy/kube-mongo.yml @@ -0,0 +1,70 @@ +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1beta1 +metadata: + name: gce-disk +provisioner: kubernetes.io/gce-pd +parameters: + type: pd-ssd + +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: mongo-volume-claim + annotations: + volume.beta.kubernetes.io/storage-class: gce-disk +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + io.codefresh.owner: codefresh + labels: + service: mongo + name: mongo +spec: + ports: + - name: "mongodb" + port: 27017 + protocol: TCP + targetPort: 27017 + selector: + service: mongo +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + annotations: + io.codefresh.owner: codefresh + name: mongo +spec: + replicas: 1 + template: + metadata: + labels: + service: mongo + spec: + containers: + - args: + - mongod + - --smallfiles + image: mongo:latest + name: mongo + ports: + - containerPort: 27017 + protocol: TCP + volumeMounts: + - mountPath: /data/db + name: mongo-data + restartPolicy: Always + volumes: + - name: mongo-data + persistentVolumeClaim: + claimName: mongo-volume-claim diff --git a/deployment.yml b/deployment.yml new file mode 100644 index 000000000..bfec9f3ed --- /dev/null +++ b/deployment.yml @@ -0,0 +1,25 @@ +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: app + labels: + service: app +spec: + replicas: 5 + template: + metadata: + annotations: + forceRedeployUniqId: "{{CF_REVISION}}" + labels: + service: app + spec: + containers: + - image: r.cfcr.io/nikolai/demochat:k8-test + name: app + imagePullPolicy: Always + ports: + - containerPort: 5000 + protocol: TCP + imagePullSecrets: + - name: rcfcrsecret diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..c0d0dc9fb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +#this is an example of a self-hosted chat app. +#the composition uses just mongo as a database and an image that was built from a demo application https://github.com/containers101/demochat + +version: '2' +services: + demochat: + build: . + ports: + - 5000 + mongo: + image: mongo diff --git a/migroose.js b/migroose.js index e27f9bac2..4f3f969d7 100644 --- a/migroose.js +++ b/migroose.js @@ -16,6 +16,7 @@ module.exports = { }, needsMigration: function(cb) { + return cb(null, false); var runner = new Runner(process.cwd(), 'migrootions'); var migrations = runner.getMigrations(); var lastMigration = migrations.slice(migrations.length - 1)[0]; diff --git a/mongo b/mongo new file mode 100644 index 000000000..eb02d5fa7 --- /dev/null +++ b/mongo @@ -0,0 +1,2 @@ +FROM mongo:latest + diff --git a/package.json b/package.json index cac06b685..ea4894733 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "scripts": { "start": "node $DEBUGGER app.js", "stop": "pkill --signal SIGINT letschat", - "prestart": "migroose", "migrate": "migroose", "test": "mocha ./app/tests" }, @@ -64,23 +63,28 @@ "dependencies": { "async": "^1.4.2", "bcryptjs": "~2.2.2", + "bluebird": "^3.5.0", + "bluebird-retry": "^0.10.1", "body-parser": "^1.14.0", + "chalk": "^1.1.3", "colors": "~1.1.2", "compression": "^1.5.2", "connect-assets": "^5.0.1", "connect-mongo": "^0.8.2", "cookie-parser": "^1.4.0", - "debug": "^2.2.0", + "debug": "^2.6.3", "express.oi": "^0.0.19", "helmet": "^0.11.0", "i18n": "^0.5.0", "js-yaml": "^3.4.2", - "less": "^2.5.1", + "kefir": "^3.7.1", + "less": "2.6.1", "lodash": "^3.10.1", "md5": "^2.0.0", "migroose": "^0.5.0", "migroose-cli": "^0.1.0", "moment": "^2.10.6", + "mongodb": "^2.2.25", "mongoose": "~4.1.8", "mongoose-unique-validator": "~0.4.1", "mongoose-validate": "0.0.5", diff --git a/templates/login.html b/templates/login.html index 8548c7437..84298e3ff 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,6 +1,6 @@ <% extends 'base.html' %> -<% block title %>Login · Let's Chat, Friends !!<% endblock %> +<% block title %>Login · Let's Chat<% endblock %> <% block class %>lcb-login animated fadeIn<% endblock %> @@ -14,7 +14,7 @@ <% block body %>
-

Let's Chat

+

Let's Chat...