diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..4bba5b1 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at captainduckduck.github atJiiiMaaaiL. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b358b4..91e9232 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,10 +25,11 @@ or your local machine itself. Needless to say, Docker is required (same minimum > Docker for Mac users: You need to add `/captain` to shared paths. > To do so, click on the Docker icon -> Setting -> File Sharing and add `/captain` -Log in to your machine, clone the git repo, go to `app-backend` directory and run the following line: +Log in to your machine, clone the git repo, go to `app-backend` directory and run the following lines: ```bash -./dev-clean-run-as-dev.sh +$ npm install +$ ./dev-clean-run-as-dev.sh ``` You are good to go! You can run the following line to see the logs for the back-end service. diff --git a/README.md b/README.md index 1388339..79ea7b3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Captain is a modern automated app deployment & web server manager. It's blazingl - Deploy apps in your own space (Node js, PHP, Python, literally any language!) - Deploying built-in apps is a matter of seconds! MongoDB, Parse, MySQL, WordPress, Postgres and many more. - Secure your services over HTTPS for FREE + - Automatic deploy from Github, Bitbucket and etc by using webhooks! - Attach more nodes and create a cluster in seconds! Captain automatically configures nginx to load balance. - Focus on your apps! Not the bells and whistles just to run your apps! diff --git a/app-backend/dist/js/dashboard.min.js b/app-backend/dist/js/dashboard.min.js index 0dff67d..c4183d7 100644 --- a/app-backend/dist/js/dashboard.min.js +++ b/app-backend/dist/js/dashboard.min.js @@ -1524,6 +1524,10 @@ function SettingsCtrl($scope, $cookieStore, $rootScope, pageDefinitions, captainToast.showToastSuccess('Update process has successfully started...'); + setTimeout(function () { + window.location.reload(true); + }, 6000); + $scope.loadingState.enabled = false; }); diff --git a/app-backend/dist/templates/apps.html b/app-backend/dist/templates/apps.html index 2995465..f569d6a 100644 --- a/app-backend/dist/templates/apps.html +++ b/app-backend/dist/templates/apps.html @@ -3,8 +3,7 @@
-
-
+
@@ -48,8 +47,7 @@
-
-
+


@@ -106,8 +104,7 @@
-
-
+


@@ -268,11 +265,11 @@
Username: - +
-
+
Password:
@@ -282,7 +279,7 @@
Repository: - +
@@ -434,7 +431,7 @@
Instance Count: - +
@@ -450,4 +447,4 @@
-
\ No newline at end of file +
diff --git a/app-backend/dist/templates/dashboard.html b/app-backend/dist/templates/dashboard.html index 51899e6..45af7a3 100644 --- a/app-backend/dist/templates/dashboard.html +++ b/app-backend/dist/templates/dashboard.html @@ -1,6 +1,5 @@
-
-
+
@@ -19,8 +18,7 @@
-
-
+
@@ -54,8 +52,7 @@
-
-
+
@@ -116,4 +113,4 @@
-
\ No newline at end of file +
diff --git a/app-backend/dist/templates/login.html b/app-backend/dist/templates/login.html index 073c0e6..f41f7e1 100644 --- a/app-backend/dist/templates/login.html +++ b/app-backend/dist/templates/login.html @@ -1,7 +1,6 @@
-
-
+
@@ -29,4 +28,4 @@
-
\ No newline at end of file +
diff --git a/app-backend/dist/templates/monitoring.html b/app-backend/dist/templates/monitoring.html index 0ec2b78..a2e49ff 100644 --- a/app-backend/dist/templates/monitoring.html +++ b/app-backend/dist/templates/monitoring.html @@ -66,8 +66,7 @@
-
-
+
@@ -294,4 +293,4 @@
-
\ No newline at end of file +
diff --git a/app-backend/dist/templates/nodes.html b/app-backend/dist/templates/nodes.html index bfc9b9e..4fcd8e8 100644 --- a/app-backend/dist/templates/nodes.html +++ b/app-backend/dist/templates/nodes.html @@ -3,8 +3,7 @@
-
-
+
@@ -12,15 +11,13 @@
-
-
+
-
-
+
@@ -28,15 +25,13 @@
-
-
+
-
-
+
@@ -44,8 +39,7 @@
-
-
+
@@ -72,8 +66,7 @@
-
-
+
@@ -104,4 +97,4 @@


-
\ No newline at end of file +
diff --git a/app-backend/dist/templates/settings.html b/app-backend/dist/templates/settings.html index fa33914..5b6d0af 100644 --- a/app-backend/dist/templates/settings.html +++ b/app-backend/dist/templates/settings.html @@ -1,6 +1,5 @@
-
-
+
@@ -44,8 +43,7 @@
-
-
+
@@ -85,4 +83,4 @@
-
\ No newline at end of file +
diff --git a/app-backend/src/datastore/DataStoreImpl.js b/app-backend/src/datastore/DataStoreImpl.js index b84dd75..94393b1 100644 --- a/app-backend/src/datastore/DataStoreImpl.js +++ b/app-backend/src/datastore/DataStoreImpl.js @@ -428,8 +428,12 @@ class DataStore { .then(function (appPushWebhookRepoInfo) { instanceCount = Number(instanceCount); + + if (instanceCount >= 0) { + app.instanceCount = instanceCount; + } - app.instanceCount = instanceCount; + app.notExposeAsWebApp = !!notExposeAsWebApp; app.nodeId = nodeId; @@ -812,4 +816,4 @@ class DataStore { } -module.exports = DataStore; \ No newline at end of file +module.exports = DataStore; diff --git a/app-backend/src/injection/Injector.js b/app-backend/src/injection/Injector.js index ab4a12a..2addc4a 100644 --- a/app-backend/src/injection/Injector.js +++ b/app-backend/src/injection/Injector.js @@ -106,7 +106,7 @@ module.exports.injectUserForWebhook = function () { app = appFound; if (app.appPushWebhook.tokenVersion !== decodedInfo.tokenVersion) { - Logger.e('Token Info do not match') + throw new Error('Token Info do not match'); } let user = { diff --git a/app-backend/src/routes/WebhooksRouter.js b/app-backend/src/routes/WebhooksRouter.js index 54b5302..e80056e 100644 --- a/app-backend/src/routes/WebhooksRouter.js +++ b/app-backend/src/routes/WebhooksRouter.js @@ -7,6 +7,31 @@ const ApiStatusCodes = require('../api/ApiStatusCodes'); const Logger = require('../utils/Logger'); const CaptainConstants = require('../utils/CaptainConstants'); + +router.post('/triggerbuild', function (req, res, next) { + + // find which branch is pushed + // inject it in locals.pushedBranches + + let isGithub = req.header('X-GitHub-Event') === 'push'; + let isBitbucket = (req.header('X-Event-Key') === 'repo:push') && req.header('X-Request-UUID') && req.header('X-Hook-UUID'); + + res.locals.pushedBranches = []; + + if (isGithub) { + let ref = req.body.ref; // "ref/heads/somebranch" + res.locals.pushedBranches.push(ref.substring(11, ref.length)); + } + else if (isBitbucket) { + for (let i = 0; i < req.body.push.changes.length; i++) { + res.locals.pushedBranches.push(req.body.push.changes[i].new.name); + } + } + + next(); + +}); + router.post('/triggerbuild', function (req, res, next) { res.sendStatus(200); @@ -15,7 +40,7 @@ router.post('/triggerbuild', function (req, res, next) { let app = res.locals.app; let namespace = res.locals.user.namespace; - if (!app || !serviceManager || !namespace|| !appName) { + if (!app || !serviceManager || !namespace || !appName) { Logger.e('Something went wrong during trigger build. Cannot extract app information from the payload.'); return; } @@ -28,14 +53,34 @@ router.post('/triggerbuild', function (req, res, next) { }) .then(function (repoInfo) { - return serviceManager.createImage(appName, { - repoInfo: repoInfo - }); + // if we didn't detect any branches, the POST might have come from another source that we don't + // explicitly support. Therefore, we just let it go through and triggers a build anyways + if (res.locals.pushedBranches.length > 0) { + let branchIsTracked = false; - }) - .then(function (version) { + for (let i = 0; i < res.locals.pushedBranches.length; i++) { + if (res.locals.pushedBranches[i] === repoInfo.branch) { + branchIsTracked = true; + break; + } + } - return serviceManager.ensureServiceInitedAndUpdated(appName, version); + // POST call was triggered due to another branch being pushed. We don't need to trigger the build. + if (!branchIsTracked) { + return; + } + + } + + return serviceManager + .createImage(appName, { + repoInfo: repoInfo + }) + .then(function (version) { + + return serviceManager.ensureServiceInitedAndUpdated(appName, version); + + }); }) .catch(function (error) { diff --git a/app-backend/src/template/root-nginx-conf.ejs b/app-backend/src/template/root-nginx-conf.ejs index 52ccc73..10a4467 100644 --- a/app-backend/src/template/root-nginx-conf.ejs +++ b/app-backend/src/template/root-nginx-conf.ejs @@ -24,7 +24,7 @@ server { listen 80; - client_max_body_size 200m; + client_max_body_size 300m; <% if (captain.hasRootSsl) { @@ -71,7 +71,7 @@ server { listen 80; - client_max_body_size 200m; + client_max_body_size 300m; <% if (registry.hasRootSsl) { %> diff --git a/app-backend/src/template/server-block-conf.ejs b/app-backend/src/template/server-block-conf.ejs index 1793f12..68524e9 100644 --- a/app-backend/src/template/server-block-conf.ejs +++ b/app-backend/src/template/server-block-conf.ejs @@ -6,7 +6,6 @@ server { listen 80; - <% if (s.hasSsl) { %> @@ -17,6 +16,7 @@ } %> + client_max_body_size 500m; server_name <%-s.publicDomain%>; diff --git a/app-backend/src/user/TemplateHelper.js b/app-backend/src/user/TemplateHelper.js index 3178214..dbce883 100644 --- a/app-backend/src/user/TemplateHelper.js +++ b/app-backend/src/user/TemplateHelper.js @@ -16,6 +16,7 @@ function getTagsForImage(imageBaseName, url, allTags) { function (error, response, body) { if (error || !body) { + Logger.e(error); reject(error); return; } @@ -29,6 +30,7 @@ function getTagsForImage(imageBaseName, url, allTags) { } if (!results) { + Logger.e('NO RESULT'); reject(new Error('NO RESULT')); return; } diff --git a/app-backend/src/utils/CaptainConstants.js b/app-backend/src/utils/CaptainConstants.js index 6f67841..14de5bf 100644 --- a/app-backend/src/utils/CaptainConstants.js +++ b/app-backend/src/utils/CaptainConstants.js @@ -24,7 +24,7 @@ let data = { isDebug: EnvVars.CAPTAIN_IS_DEBUG, - version: '0.2.2', + version: '0.3.0', captainSaltSecretKey: 'captain-salt', diff --git a/app-cli/package.json b/app-cli/package.json index e359b9c..185a313 100644 --- a/app-cli/package.json +++ b/app-cli/package.json @@ -1,6 +1,6 @@ { "name": "captainduckduck", - "version": "1.0.6", + "version": "1.0.7", "description": "CLI tool for CaptainDuckDuck. See CaptainDuckDuck.com for more details.", "main": "captainduckduck.js", "scripts": { diff --git a/app-frontend/src/js/controllers/settings-ctrl.js b/app-frontend/src/js/controllers/settings-ctrl.js index b2c01a7..dd6b635 100644 --- a/app-frontend/src/js/controllers/settings-ctrl.js +++ b/app-frontend/src/js/controllers/settings-ctrl.js @@ -60,6 +60,10 @@ function SettingsCtrl($scope, $cookieStore, $rootScope, pageDefinitions, captainToast.showToastSuccess('Update process has successfully started...'); + setTimeout(function () { + window.location.reload(true); + }, 6000); + $scope.loadingState.enabled = false; }); diff --git a/app-frontend/src/templates/apps.html b/app-frontend/src/templates/apps.html index d9cbeb9..5a50e12 100644 --- a/app-frontend/src/templates/apps.html +++ b/app-frontend/src/templates/apps.html @@ -3,8 +3,7 @@
-
-
+
@@ -48,8 +47,7 @@
-
-
+


@@ -106,8 +104,7 @@
-
-
+


@@ -269,11 +266,11 @@
Username: - +
-
+
Password:
@@ -283,7 +280,7 @@
Repository: - +
@@ -436,7 +433,7 @@
Instance Count: - +
@@ -452,4 +449,4 @@
-
\ No newline at end of file +
diff --git a/app-frontend/src/templates/dashboard.html b/app-frontend/src/templates/dashboard.html index 412fa10..40c169f 100644 --- a/app-frontend/src/templates/dashboard.html +++ b/app-frontend/src/templates/dashboard.html @@ -1,6 +1,5 @@
-
-
+
@@ -19,8 +18,7 @@
-
-
+
@@ -59,8 +57,7 @@
-
-
+
@@ -121,4 +118,4 @@
-
\ No newline at end of file +
diff --git a/app-frontend/src/templates/login.html b/app-frontend/src/templates/login.html index 073c0e6..f41f7e1 100644 --- a/app-frontend/src/templates/login.html +++ b/app-frontend/src/templates/login.html @@ -1,7 +1,6 @@
-
-
+
@@ -29,4 +28,4 @@
-
\ No newline at end of file +
diff --git a/app-frontend/src/templates/monitoring.html b/app-frontend/src/templates/monitoring.html index a33cbb5..37836ea 100644 --- a/app-frontend/src/templates/monitoring.html +++ b/app-frontend/src/templates/monitoring.html @@ -66,8 +66,7 @@
-
-
+
@@ -304,4 +303,4 @@
-
\ No newline at end of file +
diff --git a/app-frontend/src/templates/nodes.html b/app-frontend/src/templates/nodes.html index 0bd3b90..2bff540 100644 --- a/app-frontend/src/templates/nodes.html +++ b/app-frontend/src/templates/nodes.html @@ -3,8 +3,7 @@
-
-
+
@@ -12,15 +11,13 @@
-
-
+
-
-
+
@@ -28,15 +25,13 @@
-
-
+
-
-
+
@@ -44,8 +39,7 @@
-
-
+