diff --git a/docs/To-Be-Converted/Deployment-Methods.md b/docs/To-Be-Converted/Deployment-Methods.md deleted file mode 100644 index 80c0c3d..0000000 --- a/docs/To-Be-Converted/Deployment-Methods.md +++ /dev/null @@ -1,69 +0,0 @@ -Regardless of your deployment method, make sure that you have a 'captain-definition' file in your project. See docs for more details: -https://github.com/githubsaturn/captainduckduck/wiki/Captain-Definition-File - -## Deploy via CLI -Simply run `captainduckduck deploy` in your git repo and follow the steps. This is the best method as it's the only method that reports potential build failures to you. Read more about it here: -https://github.com/githubsaturn/captainduckduck/wiki/Getting-Started#step-4-deploy-the-test-app - -## Deploy via Web Dashboard -Zip the content of your project into a tarball (`.tar`), go to your Captain web dashboard and upload the tar file. - - -## Deploy using Github, Bitbucket and etc. -This method is perhaps the most convinient one. This method automatically triggers a build when you push your repo to a specific branch (like `master` or `staging` or etc). To setup this, go to your apps settings and enter the repo information: -- github/bitbucket username(email address): This is username that will be used when Captain downloads the repo. -- github/bitbucket password: You can enter any non-empty text, like `123456`, for public projects. -- repo: This is the main HTTPS address of repo, in case of github, it is in `github.com/someone/something` format. -- branch: The branch you want to be tracked, for example `master` or `production`... - -After you enter this information, save your configuration. And go to your apps page again. Now, you'll see a new field call webhook. Simply copy this webhook to your github/bitbucket repo. Captain listens to `POST` requests on this link and triggers a build. - -On Github, webhooks can be added here: -- Project > Settings > Add Webhook > URL: Captain Webhook from your apps page, Content Type: `application/json`, -Secret: , Just the `push` event. - -On Bitbucket, webhooks can be added here: -- Project > Settings > Webhooks > Add Webhook > Title: Captain Server, URL: Captain Webhook from your apps page. - - -## Post Deploy Script -This script will run right before your container (i.e. app) gets updated due to a configuration change or app deploy. In this script, you can modify the Docker service object, invoke an HTTP call, and literally do anything. The template for this script is: -``` -var preDeployFunction = function (captainAppObj, dockerUpdateObject) { - return Promise.resolve() - .then(function(){ - - // Do something in a Promise form - - // In the end, return the "possibly-modified" dockerUpdateObject - return dockerUpdateObject; - }); -}; - -``` - -Note that `captainAppObj`, is the app object as saved in `/captain/config.conf` file, and `dockerUpdateObject` is the service update object that is being passed to Docker to update the service (environmental vars, image version and etc). This object is as per [Docker docs].(https://docs.docker.com/engine/api/v1.30/#operation/ServiceUpdate) - -Since this script will be executed in CaptainDuckDuck process, you'll get access to all node dependecies that CaptainDuckDuck has, see [here](https://github.com/githubsaturn/captainduckduck/blob/master/app-backend/package.json). For example, the following script injects a UUID mapped to the deployed version to service label with every update: - -``` -var uuid = require('uuid/v4'); - -var preDeployFunction = function (captainAppObj, dockerUpdateObject) { - return Promise.resolve() - .then(function(){ - - dockerUpdateObject.TaskTemplate.ContainerSpec.Labels[uuid()] = captainAppObj.deployedVersion+ ''; - return dockerUpdateObject; - }); -}; - -``` - -Note that this pre-deploy script, particularly Docker service update object, is complicated. Hence, it is strongly recommended to use this pre-deploy method if you are an expert user. For example, note that how an empty string is being added to the deployed version in this line: - -``` -dockerUpdateObject.TaskTemplate.ContainerSpec.Labels[uuid()] = captainAppObj.deployedVersion+ ''; -``` - -Removing this causes an error. To see logs, you need to run `docker service logs captain-captain --follow`. Even the error from Docker is not very clear. All in all, this is an advanced feature and is not recommended for beginners and intermiate users. \ No newline at end of file diff --git a/docs/To-Be-Converted/Disk-Clean-Up.md b/docs/To-Be-Converted/Disk-Clean-Up.md deleted file mode 100644 index 331711f..0000000 --- a/docs/To-Be-Converted/Disk-Clean-Up.md +++ /dev/null @@ -1,18 +0,0 @@ -Docker uses the disk in different ways: - -- Saving your images: images are compressed files with your built source-code that you deployed to the server. Every time you deploy a new version of your code, Docker builds a new image for the new version and keeps the old image by default. If you want to clean up all "unused" images on your server, run -``` -docker container prune --force -docker image prune --all -``` - -Important Note: Use this approach only if you have a Docker registry set up (local or remote). This is due to an existing bug in Docker, see [here](https://github.com/githubsaturn/captainduckduck/issues/180) for more details on the problem and also see the related [Docker Issue](https://github.com/moby/moby/issues/36295) - -- Volumes, aka "Persistent Directories". When you create an app with persistent data, like a database, you will assign it a persistent directory. When you change the persistent directory, or when you delete your app, you don't need the volumes anymore. Cleaning up orphaned volumes are tricky. If you have a useful volume for an app that is "currently" crashing and not-running, that volume is considered as "orphaned" by Docker :( So, to safely clean up orphaned volumes, first, check to see if all your services are running by: -``` -docker service ls -``` -Under REPLICAS, you should see `1/1`, `2/2` and etc. If you see a service that is not running, then do not proceed! Otherwise, go head and clean-up orphaned volumes by: -``` -docker volume prune -``` \ No newline at end of file diff --git a/docs/To-Be-Converted/Monitoring.md b/docs/To-Be-Converted/Monitoring.md deleted file mode 100644 index 728cada..0000000 --- a/docs/To-Be-Converted/Monitoring.md +++ /dev/null @@ -1,6 +0,0 @@ -### Resource Consumption of Server: - -You want to see how your app is behaving. Is it eating up your memory or CPU? Or is your network connection slow? You can answer all these questions by visiting Captain Monitoring menu from the web dashboard. You can enable [NetData](https://github.com/firehol/netdata) which is a server monitoring tool and monitor your server. - - -![](https://cloud.githubusercontent.com/assets/2662304/14092712/93b039ea-f551-11e5-822c-beadbf2b2a2e.gif) \ No newline at end of file diff --git a/docs/app-configuration.md b/docs/app-configuration.md index f413a0b..7df0c71 100644 --- a/docs/app-configuration.md +++ b/docs/app-configuration.md @@ -6,7 +6,16 @@ sidebar_label: App Configuration
-## Persistent Data +## Custom Domains & HTTPS + +By default, any webapp that you deploy gets a Captain domain assigned to it in this format: `appname.root.domain.com`. However, you have the option to add as many domains as you want to this app. For example, you can add `www.myawesomeapp.com` and `myawesomeapp.com`. + + +## Environmental Variables + +One of the most basic configuration that you can set for your app is environmental variables. These variables are usually used to pass in data that does not live in the code. Examples, include API key for a 3rd party service, database connection URI and etc. + +## Persistent or Not When you want to create an app you have the option of creating the app with "Persistent Data" or not. @@ -39,6 +48,6 @@ Also, multiple instances of non-persistent apps can be running at the same time ## Port Mapping -CaptainDuckDuck allows you to map ports from a container to the host. You should use this feature if you want a specific port of your apps/containers to be publicly accessible. The most common use case is when you want to connect to a database container from your local machine. Note that even if you don't set any port mapping, all ports are accessible from other containers on the same Captain cluster. Therefore, you should only use this option if you want the port to be publicly accessible. Make sure to have the port open, see [firewall settings](https://github.com/githubsaturn/captainduckduck/wiki/Firewall#firewall--port-forwarding). +CaptainDuckDuck allows you to map ports from a container to the host. You should use this feature if you want a specific port of your apps/containers to be publicly accessible. The most common use case is when you want to connect to a database container from your local machine. Note that even if you don't set any port mapping, all ports are accessible from other containers on the same Captain cluster. Therefore, you should only use this option if you want the port to be publicly accessible. Make sure to have the port open, see [firewall settings](firewall.md). Note that you only need port mapping if your database is being accessed from an external machine. For example, if you want your NodeJS app to access your MongoDB database, and you do not need to access your MongoDB from your laptop, you don't need Port Mapping. Instead, you can use the fully qualified name for the MongoDB instance which is `srv-captain--mongodb-app-name` (replace `mongodb-app-name` with the app name you used). diff --git a/docs/To-Be-Converted/Server-Clustering-and-App-Scaling.md b/docs/app-scaling-and-cluster.md similarity index 91% rename from docs/To-Be-Converted/Server-Clustering-and-App-Scaling.md rename to docs/app-scaling-and-cluster.md index fb37b80..21c35d2 100644 --- a/docs/To-Be-Converted/Server-Clustering-and-App-Scaling.md +++ b/docs/app-scaling-and-cluster.md @@ -1,8 +1,18 @@ -### Run Multiple Instances of App: +--- +id: app-scaling-and-cluster +title: App Scaling & Cluster +sidebar_label: App Scaling & Cluster +--- + +
+ +Captain offers you multiple ways to scale up your app, running it on multiple processes and benefit from all resources on your server. + +## Run Multiple Instances of App: Your Pizza app is doing great and you are getting thousands of hits on your website. Having one instance of your app is not good enough. Your latency has gone up. Next thing you want is to consider to run multiple instances of your app on your Captain. You can do this from the Apps section of Captain web. Let's say you change your instance count to 3. Captain creates 3 instances of your app running at the same time. If any of them dies (crashes), it automatically spins off a new one! You always have 3 instances of your Pizza app running! The best part? Captain automatically spreads the requests between different instances of your app. -### Run Multiple Servers: +## Run Multiple Servers: Wow! Your Pizza app is really popular! You have 3 instances of your app running on the same server, RAM and CPU are almost maxed out. You need to get a second server. How do you connect the servers? Captain does that for you ;-) You simply get a server with Docker installed on it, similar to what you did for the original Captain server. diff --git a/docs/captain-definition-file.md b/docs/captain-definition-file.md index 002170f..18abc52 100644 --- a/docs/captain-definition-file.md +++ b/docs/captain-definition-file.md @@ -16,9 +16,9 @@ One of the key components of CaptainDuckDuck is the `captain-definition` file th } ``` -`schemaVersion` is always 1. And `templateId` is the piece which defines the what sort of base you need in order to run your app. It is in LANGUAGE/VERSION format. LANGUAGE can be one of these: `node`, `php`, `python-django`, `ruby-rack`. See supported versions below for the versions. +`schemaVersion` is always 1. And `templateId` is the piece which defines the what sort of base you need in order to run your app. It is in `LANGUAGE/VERSION` format. LANGUAGE can be one of these: `node`, `php`, `python-django`, `ruby-rack`. See supported versions below for the versions. -Note that although the current version of CaptainDuckDuck comes with 3 most popular web app languages: NodeJS, PHP and Python/Django, Ruby/Rack. It gives you the advanced option of defining your own Dockerfile. For example, the two captain-definition files below generate the exact same result. +Note that although the current version of CaptainDuckDuck comes with 4 most popular web app languages: NodeJS, PHP and Python/Django, Ruby/Rack. It gives you the advanced option of defining your own Dockerfile. With a customized Dockerfile, you can deploy any laguage, Go, Java, .NET, you name it! Dockerfiles are quite easy to write. For example, the two captain-definition files below generate the exact same result. ### Simple version @@ -53,17 +53,14 @@ Note that although the current version of CaptainDuckDuck comes with 3 most popu You can use [this tool](https://githubsaturn.github.io/dockerfile-to-captain/) to convert your `Dockerfile` to `captain-definition` file easily. This [NodeJS script](https://github.com/githubsaturn/captainduckduck/issues/214) is also for the same purpose, except, it automatically adds `.src/` to the `COPY` lines. -Even if you don't know anything about Docker, you can get an idea what this does. Some examples of advanced methods: -- PHP Composer: https://github.com/githubsaturn/captainduckduck/issues/94 -- Meteor: https://github.com/githubsaturn/meteor-captainduckduck/blob/master/captain-definition +Even if you don't know anything about Docker, you can get an idea what this does. Some examples of advanced methods: [PHP Composer](https://github.com/githubsaturn/captainduckduck/issues/94) and [Meteor](https://github.com/githubsaturn/meteor-captainduckduck/blob/master/captain-definition) -**IMPORANT NOTE:** Captain generates a dockerfile and puts it besides a directory named `src` where your source code sits. So if in your normal dockerfile, you have `COPY ./somefile /usr/app`, you will have to change it to `COPY ./src/somefile /usr/app` otherwise deploy would fail. -Using this approach you can deploy Ruby, Java, Scala, literally everything! As Captain becomes more mature, more and more languages will be added to the built-in template, so you don't have to create the dockerfile manually like above. If you need more details on dockerfile, please see: +**IMPORANT NOTE:** +
+Captain generates a dockerfile and puts it besides a directory named `src` where your source code sits. So if in your normal dockerfile, you have `COPY ./somefile /usr/app`, you will have to change it to `COPY ./src/somefile /usr/app` otherwise deploy would fail. -https://docs.docker.com/engine/reference/builder/ -and -https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/ +Using this approach you can deploy Ruby, Java, Scala, literally everything! If you need more details on dockerfile, please see [Dockerfile Help](https://docs.docker.com/engine/reference/builder) and [Best Practices](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices). ## Supported versions for simple version: diff --git a/docs/To-Be-Converted/Complete-Webapp-Tutorial.md b/docs/complete-webapp-tutorial.md similarity index 97% rename from docs/To-Be-Converted/Complete-Webapp-Tutorial.md rename to docs/complete-webapp-tutorial.md index 80245be..c7a9875 100644 --- a/docs/To-Be-Converted/Complete-Webapp-Tutorial.md +++ b/docs/complete-webapp-tutorial.md @@ -1,3 +1,11 @@ +--- +id: complete-webapp-tutorial +title: Complete Webapp Tutorial +sidebar_label: Complete Webapp Tutorial +--- + + +
We want to make a webapp version of HOTDOG or NOT HOTDOG: https://www.theverge.com/2017/6/26/15876006/hot-dog-app-android-silicon-valley @@ -60,4 +68,4 @@ mongoose.connect("mongodb://srv-captain--my-mongodb/mydatabase", { useMongoClien Of course, you can add username and password to the URI, see here for example: https://stackoverflow.com/questions/7486623/mongodb-password-with-in-it -This is the same for other services; if you want to upload an image to your image uploader service you can just access it via `http://srv-captain--imageuploader` \ No newline at end of file +This is the same for other services; if you want to upload an image to your image uploader service you can just access it via `http://srv-captain--imageuploader` diff --git a/docs/deployment-methods.md b/docs/deployment-methods.md new file mode 100644 index 0000000..cc58c2b --- /dev/null +++ b/docs/deployment-methods.md @@ -0,0 +1,34 @@ +--- +id: deployment-methods +title: Deployment Methods +sidebar_label: Deployment Methods +--- + +
+Regardless of your deployment method, make sure that you have a 'captain-definition' file in your project. See docs on [Captain Definition](captain-definition-file.md) for more details. + +## Deploy via CLI +Simply run `captainduckduck deploy` in your git repo and follow the steps. This is the best method as it's the only method that reports potential build failures to you. Read more about it here: + [Get Started - Step 4](get-started.md#step-4-deploy-the-test-app). + +## Deploy via Web Dashboard +Zip the content of your project into a tarball (`.tar`), go to your Captain web dashboard and upload the tar file. + + +## Deploy using Github, Bitbucket and etc. +This method is perhaps the most convinient one. This method automatically triggers a build when you push your repo to a specific branch (like `master` or `staging` or etc). To setup this, go to your apps settings and enter the repo information: +- github/bitbucket username(email address): This is username that will be used when Captain downloads the repo. +- github/bitbucket password: You can enter any non-empty text, like `123456`, for public projects. +- repo: This is the main HTTPS address of repo, in case of github, it is in `github.com/someone/something` format. +- branch: The branch you want to be tracked, for example `master` or `production`... + +After you enter this information, save your configuration. And go to your apps page again. Now, you'll see a new field call webhook. Simply copy this webhook to your github/bitbucket repo. Captain listens to `POST` requests on this link and triggers a build. + +On Github, webhooks can be added here: +- Project > Settings > Add Webhook > URL: Captain Webhook from your apps page, Content Type: `application/json`, +Secret: , Just the `push` event. + +On Bitbucket, webhooks can be added here: +- Project > Settings > Webhooks > Add Webhook > Title: Captain Server, URL: Captain Webhook from your apps page. + + diff --git a/docs/disk-cleanup.md b/docs/disk-cleanup.md new file mode 100644 index 0000000..abbb5b4 --- /dev/null +++ b/docs/disk-cleanup.md @@ -0,0 +1,34 @@ +--- +id: disk-cleanup +title: Disk Clean-Up +sidebar_label: Disk Clean-Up +--- + +
+ +Docker uses the disk in different ways: + +## Docker Images +Saving your images: images are compressed files with your built source-code that you deployed to the server. Every time you deploy a new version of your code, Docker builds a new image for the new version and keeps the old image by default. If you want to clean up all "unused" images on your server, run +``` +docker container prune --force +docker image prune --all +``` + +Important Note: Use this approach only if you have a Docker registry set up (local or remote). This is due to an existing bug in Docker, see [here](https://github.com/githubsaturn/captainduckduck/issues/180) for more details on the problem and also see the related [Docker Issue](https://github.com/moby/moby/issues/36295) + +## Docker Volumes +Volumes, aka "Persistent Directories". When you create an app with persistent data, like a database, you will assign it a persistent directory. When you change the persistent directory, or when you delete your app, you don't need the volumes anymore. Cleaning up orphaned volumes are tricky. If you have a useful volume for an app that is "currently" crashing and not-running, that volume is considered as "orphaned" by Docker :( So, to safely clean up orphaned volumes, first, check to see if all your services are running by: +``` +docker service ls +``` +Under REPLICAS, you should see `1/1`, `2/2` and etc. If you see a service that is not running, then do not proceed! Otherwise, go head and clean-up orphaned volumes by: +``` +docker volume prune +``` + +Alternatively, you can first list all volumes, and delete only the ones that you don't want: +``` +docker volume ls # lists all volumes +docker volume rm volume-name-goes-here # removes a specific volume +``` diff --git a/docs/To-Be-Converted/HTTPS-for-Captain-and-Apps.md b/docs/enabling-https.md similarity index 69% rename from docs/To-Be-Converted/HTTPS-for-Captain-and-Apps.md rename to docs/enabling-https.md index 64f6031..e9c6d31 100644 --- a/docs/To-Be-Converted/HTTPS-for-Captain-and-Apps.md +++ b/docs/enabling-https.md @@ -1,7 +1,17 @@ -### Enable HTTPS on Captain: +--- +id: enabling-https +title: Enabling HTTPS +sidebar_label: Enabling HTTPS +--- + +
+ +CaptainDuckDuck has built-in support for Let's Encrypt and it enables you to easily put your websites behind secure HTTPS without being concerned with the cost of SSL certificates (Let's Encrypt is free) and without any hassle of setting up configs and renewing certificates. + +## Enable HTTPS on Captain: One of the benefits of Captain, is the ONE CLICK HTTPS activation. Simply click on Enable HTTPs on your dashboard and after a couple of seconds your HTTPS is enabled. Note that once HTTPS is enabled, you cannot change your root domain, i.e. `something.mydomain.com`, of course it's always possible to re-install Captain and change it. After enabling HTTPS, you can optionally, although very recommended, enforce HTTPS for all requests, i.e. denying plain insecure HTTP connections and redirect them to HTTPS. Make sure you manually check HTTPS before doing this. Simply go to `https://captain.something.mydomain.com` and if it works, you can safely force HTTPS. -### Enable HTTPS for Apps: +## Enable HTTPS for Apps: You have full control over enabling HTTPS on your own apps. Once Captain root HTTPS is enabled, you can enable HTTPS for individual apps. To do so, simply go to Captain web, select Apps from the left side menu, scroll to your desired app, and click on Enable HTTPS. That's it! diff --git a/docs/To-Be-Converted/Home.md b/docs/examples/To-Be-Converted/Home.md similarity index 100% rename from docs/To-Be-Converted/Home.md rename to docs/examples/To-Be-Converted/Home.md diff --git a/docs/To-Be-Converted/Firewall.md b/docs/firewall.md similarity index 85% rename from docs/To-Be-Converted/Firewall.md rename to docs/firewall.md index 596d4e5..820117c 100644 --- a/docs/To-Be-Converted/Firewall.md +++ b/docs/firewall.md @@ -1,4 +1,11 @@ -### Firewall & Port Forwarding +--- +id: firewall +title: Firewall & Port Forwarding +sidebar_label: Firewall & Port Forwarding +--- + +
+ Captain uses: - 80 TCP for regular HTTP connections @@ -11,4 +18,4 @@ Captain uses: Or simply disable firewall entirely. In case of an ubuntu server, run `ufw disable`. -Also, if you are using Port Mapping to allow external connections, for example from your laptop to a MySQL instance on Captain, you will have to add the corresponding port to the exclusion as well. \ No newline at end of file +Also, if you are using Port Mapping to allow external connections, for example from your laptop to a MySQL instance on Captain, you will have to add the corresponding port to the exclusion as well. diff --git a/docs/get-started.md b/docs/get-started.md index d524869..b241cbd 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -36,7 +36,6 @@ Some server providers have strict firewall settings. To disable firewall on Ubun ufw disable ``` -


@@ -93,4 +92,4 @@ You can connect multiple custom domains (like `www.my-app.com`) to a single app Note that when you run `captainduckduck deploy`, the current git commit will be sent over to your server. **IMPORTANT:** uncommited files and files in `gitignore` WILL NOT get pushed to the server. -You can visit Captain in the browser and set custom parameters for your app such as environment variables, and do much more! For more details regarding deployment, please see CLI docs. For details on `captain-definition` file, see [Captain Definition File](https://github.com/githubsaturn/captainduckduck/wiki/Captain-Definition-File) in wiki. +You can visit Captain in the browser and set custom parameters for your app such as environment variables, and do much more! For more details regarding deployment, please see CLI docs. For details on `captain-definition` file, see [Captain Definition File](captain-definition-file.md). diff --git a/docs/To-Be-Converted/NGINX-Customization.md b/docs/nginx-customization.md similarity index 96% rename from docs/To-Be-Converted/NGINX-Customization.md rename to docs/nginx-customization.md index 72539fd..8021a16 100644 --- a/docs/To-Be-Converted/NGINX-Customization.md +++ b/docs/nginx-customization.md @@ -1,3 +1,9 @@ +--- +id: nginx-customization +title: NGINX Config +sidebar_label: NGINX Config +--- + ## Config Customization Although CaptainDuckDuck automatically manages everything about routing HTTP requests to your apps, there might still be some special config values that you want to manually tweak. It can be special caching logic for special file type or route, timeout customization, max body size and many more parameters that you can manually adjust via nginx. @@ -10,4 +16,4 @@ Once you've changed the template, you can see the compiled version of your nginx ## Custom Files and Directories -On top of config customization, you might need to use some files in your nginx container, things such as custom SSL certs, specific static assets and etc. Since in CaptainDuckDuck instance, everything (including nginx) is sitting in a separate container, you'll need to map a directory from your host to the container. Captain already did that for you. The directory `/captain/nginx-shared` in your server is available in your nginx container as `/nginx-shared`. Let's say you place a custom SSL cert in that folder and call it `/captain/nginx-shared/custom-cert.pem`. In order to reference that file in your nginx config, you'll use `/nginx-shared/custom-cert.pem` \ No newline at end of file +On top of config customization, you might need to use some files in your nginx container, things such as custom SSL certs, specific static assets and etc. Since in CaptainDuckDuck instance, everything (including nginx) is sitting in a separate container, you'll need to map a directory from your host to the container. Captain already did that for you. The directory `/captain/nginx-shared` in your server is available in your nginx container as `/nginx-shared`. Let's say you place a custom SSL cert in that folder and call it `/captain/nginx-shared/custom-cert.pem`. In order to reference that file in your nginx config, you'll use `/nginx-shared/custom-cert.pem` diff --git a/docs/To-Be-Converted/One-Click-Apps.md b/docs/one-click-apps.md similarity index 87% rename from docs/To-Be-Converted/One-Click-Apps.md rename to docs/one-click-apps.md index a166bc5..492ec49 100644 --- a/docs/To-Be-Converted/One-Click-Apps.md +++ b/docs/one-click-apps.md @@ -1,4 +1,11 @@ -## One-Click Apps +--- +id: one-click-apps +title: One-Click Apps +sidebar_label: One-Click Apps +--- + +
+ CaptainDuckDuck has built-in support for several popular apps that can be deployed as is. These include WordPress, MySQL, MongoDB and etc. ![OneClickAppsCaptainDuckDuck](https://i.imgur.com/Tlgbkmy.png) @@ -17,4 +24,4 @@ However, if you want to connect to your database from a remote machine (e.g. you - Port 1001 of the server goes to mysql-1 port 3306 - Port 1002 of the server goes to mysql-2 port 3306 -Port mapping is needed if you want to connect to a database from a remote machine. You can read more about it [here](https://github.com/githubsaturn/captainduckduck/wiki/App-Configuration#port-mapping). \ No newline at end of file +Port mapping is needed if you want to connect to a database from a remote machine. You can read more about it [Captain Configuration - Port Mapping](app-configuration.md#port-mapping). diff --git a/docs/pre-deploy-script.md b/docs/pre-deploy-script.md new file mode 100644 index 0000000..a137309 --- /dev/null +++ b/docs/pre-deploy-script.md @@ -0,0 +1,50 @@ +--- +id: pre-deploy-script +title: Pre-deploy Script +sidebar_label: Pre-deploy Script +--- + +
+This is a very advanced operation and requires attention. Otherwise, it can break the deployment for your app. + +This script will run right before your container (i.e. app) gets updated due to a configuration change or app deploy. In this script, you can modify the Docker service object, invoke an HTTP call, and literally do anything. The template for this script is: +``` +var preDeployFunction = function (captainAppObj, dockerUpdateObject) { + return Promise.resolve() + .then(function(){ + + // Do something in a Promise form + + // In the end, return the "possibly-modified" dockerUpdateObject + return dockerUpdateObject; + }); +}; + +``` + +Note that `captainAppObj`, is the app object as saved in `/captain/config.conf` file, and `dockerUpdateObject` is the service update object that is being passed to Docker to update the service (environmental vars, image version and etc). This object is as per [Docker docs](https://docs.docker.com/engine/api/v1.30/#operation/ServiceUpdate). + +Since this script will be executed in CaptainDuckDuck process, you'll get access to all node dependecies that CaptainDuckDuck has, see [CaptainDuckDuck/app-backend/package.json](https://github.com/githubsaturn/captainduckduck/blob/master/app-backend/package.json). For example, the following script injects a UUID mapped to the deployed version to service label with every update: + +``` +var uuid = require('uuid/v4'); + +var preDeployFunction = function (captainAppObj, dockerUpdateObject) { + return Promise.resolve() + .then(function(){ + + dockerUpdateObject.TaskTemplate.ContainerSpec.Labels[uuid()] = + captainAppObj.deployedVersion+ ''; + return dockerUpdateObject; + }); +}; + +``` + +Note that this pre-deploy script, particularly Docker service update object, is complicated. Hence, it is strongly recommended to use this pre-deploy method if you are an expert user. For example, note that how an empty string is being added to the deployed version in this line: + +``` +dockerUpdateObject.TaskTemplate.ContainerSpec.Labels[uuid()] = captainAppObj.deployedVersion+ ''; +``` + +Removing this causes an error. To see logs, you need to run `docker service logs captain-captain --follow`. Even the error from Docker is not very clear. All in all, this is an advanced feature and is not recommended for beginners and intermiate users. diff --git a/docs/resource-monitoring.md b/docs/resource-monitoring.md new file mode 100644 index 0000000..a9bc4e3 --- /dev/null +++ b/docs/resource-monitoring.md @@ -0,0 +1,11 @@ +--- +id: resource-monitoring +title: Resource Monitoring +sidebar_label: Resource Monitoring +--- +
+ +You always want to see how your app is behaving. Is it eating up your memory or CPU? Or is your network connection slow? You can answer all these questions by visiting Captain Monitoring menu from the web dashboard. You can enable [NetData](https://github.com/firehol/netdata) which is a server monitoring tool and monitor your server. + + +![](https://cloud.githubusercontent.com/assets/2662304/14092712/93b039ea-f551-11e5-822c-beadbf2b2a2e.gif) diff --git a/docs/To-Be-Converted/Run-Locally.md b/docs/run-locally.md similarity index 54% rename from docs/To-Be-Converted/Run-Locally.md rename to docs/run-locally.md index 074d051..1825884 100644 --- a/docs/To-Be-Converted/Run-Locally.md +++ b/docs/run-locally.md @@ -1,11 +1,18 @@ -In order to run CaptainDuckDuck on your local machine you need: +--- +id: run-locally +title: Run Locally +sidebar_label: Run Locally +--- + +
+Note that this is an advanced process. Some of the concepts used in this section are not easy for the beginners. In order to run CaptainDuckDuck on your local machine (just for testing and development) you need: - Docker installed on your machine. - A local DNS server on your machine. You need to point `*.captain.x` to `127.0.0.1` or `192.168.1.2` (your local ip). **NOTE** that `etc/hosts` won't be enough as Captain needs a wildcard entry and `etc/hosts` does not allow wildcards, i.e. `*.something`. - On ubuntu 16, `dnsmasq` (a local DNS server) is built-in. So, it's as simple of editing this file: `/etc/NetworkManager/dnsmasq.d/dnsmasq-localhost.conf` (create if does not exist) And add this line to it: `address=/captain.x/192.168.1.2` where `192.168.1.2` is your local IP address. To make sure you have `dnsmasq`, you can run `which dnsmasq` on your terminal, if it's available, path of it will be printed on the terminal, otherwise, there won't be anything printed on your terminal To verify you have both prerequisites mentioned above: -- Run `docker version` and make sure your version is at least the version mentioned in the [docs](https://github.com/githubsaturn/captainduckduck/wiki/Getting-Started#c-install-docker-on-server-at-least-version-1706x) +- Run `docker version` and make sure your version is at least the version mentioned in the [docs](get-started.md#c-install-docker-on-server-at-least-version-1706x) - Run `nslookup askjdfklasjflk.captain.x` and make sure it resolves to `127.0.0.1` or your local ip (something like `192.168.1.2`): ``` Server: 127.0.1.1 @@ -16,8 +23,7 @@ Address: 192.168.1.2 ``` -Once you confirmed that you have the prereqs ready, you can go ahead and install Captain on your machine, similar to what you do on server. Make sure you run as a user with sufficient permission, i.e. `sudo` on linux based systems. Just follow the steps outlined here: -https://github.com/githubsaturn/captainduckduck/wiki/Getting-Started#step-1-captain-installation +Once you confirmed that you have the prereqs ready, you can go ahead and install Captain on your machine, similar to what you do on server. Make sure you run as a user with sufficient permission, i.e. `sudo` on linux based systems. Just follow the steps outlined here: [Captain Installation](get-started#step-1-captain-installation) **EXCEPT** Do not run `captainduckduck serversetup`. Instead, go to http://localhost:3000 and manually set root domain to `captain.x`. DO NOT enable/force HTTPS. Obviously, you cannot enable HTTPS on your local domain (captain.x). @@ -31,4 +37,31 @@ To do so, click on the Docker icon -> Setting -> File Sharing and add `/captain` -You are set! \ No newline at end of file +You are set! + + +## Troubleshooting: + + +As mentioned above, running a local machine is an advanced task and might fail due to different reasons, depending on error your solution is different. For example, if you get the following error: + +``` +Captain Starting ... +Installing Captain Service ... +December 18th 2017, 11:51:11.295 pm Starting swarm at 34.232.18.13:2377 +Installation failed. +{ Error: (HTTP code 400) bad parameter - must specify a listening address because the address to advertise is not recognized as a system address, and a system's IP address to use could not be uniquely identified + at /usr/src/app/node_modules/docker-modem/lib/modem.js:254:17 + at process._tickCallback (internal/process/next_tick.js:180:9) + reason: 'bad parameter', + statusCode: 400, + json: + { message: 'must specify a listening address because the address to advertise is not recognized as a system address, and a system\'s IP address to use could not be uniquely identified' } } +``` +You can try this: + +``` +docker run -e "MAIN_NODE_IP_ADDRESS=192.168.1.2" -v /var/run/docker.sock:/var/run/docker.sock dockersaturn/captainduckduck +``` + +and replace `192.168.1.2` with your own local IP. diff --git a/docs/To-Be-Converted/Troubleshooting.md b/docs/troubleshooting.md similarity index 61% rename from docs/To-Be-Converted/Troubleshooting.md rename to docs/troubleshooting.md index 456647c..1d7a35b 100644 --- a/docs/To-Be-Converted/Troubleshooting.md +++ b/docs/troubleshooting.md @@ -1,13 +1,23 @@ -### Cannot connect :3000? +--- +id: troubleshooting +title: Troubleshooting +sidebar_label: Troubleshooting +--- + +
+ +This section covers most frequent issues that uses may encounter. + +## Cannot connect :3000? There is a whole set of reasons for this. First you need to make sure that CaptainDuckDuck is running on your server. To check this, ssh to your server and run `docker service ps captain-captain --no-trunc`. You might see Captain is getting restarted constantly due to an error. Fix the issue and retry. See here for example: https://github.com/githubsaturn/captainduckduck/issues/14 Linode for example is notorious for [this kind of problem](https://github.com/docker/machine/issues/2753#issuecomment-171822791) and [this](https://github.com/docker/machine/issues/2753#issuecomment-188353704) -If you don't see any errors when your ran `docker service ps captain-captain --no-trunc`, then try `curl localhost:3000 -v`. If successful, it's probably your firewall that's blocking the connection. See firewall section in wiki. +If you don't see any errors when your ran `docker service ps captain-captain --no-trunc`, then try `curl localhost:3000 -v`. If successful, it's probably your firewall that's blocking the connection. See [Firewall Docs](firewall.md). -### Successful Deploy but 502 bad gateway error! +## Successful Deploy but 502 bad gateway error! This applies to you if: - You have been able to setup your server and access it via `captain.rootdomain.example.com`. - You have been able to deploy one of the samples apps (see [here](https://github.com/githubsaturn/captainduckduck/tree/master/captain-sample-apps)) successfully and it worked. @@ -17,7 +27,7 @@ If all above points are correct, this is how to troubleshoot: - SSH to your server and view your application logs. Make sure it hasn't crashed and it's running. To view logs, please see the section at the end of this page "[How to view my application's log](#how-to-view-my-applications-log)" - If you application logs show that your application is running, the most common case is that your application is binding to a custom port, not port 80. See here for [the fix](https://github.com/githubsaturn/captainduckduck/issues/130) . -### Want to customize a captain dashboard URL (or any other constants) +## Want to customize a captain dashboard URL (or any other constants) You can customize any constant defined in [CaptainConstants](https://github.com/githubsaturn/captainduckduck/blob/master/app-backend/src/utils/CaptainConstants.js) by adding a JSON file to `/captain/constants.conf`. For example, to change `defaultMaxLogSize`, the content of `/captain/constants.conf` will be: ``` { @@ -26,39 +36,7 @@ You can customize any constant defined in [CaptainConstants](https://github.com/ ``` -### Cannot run on local machine -Again, there is a ton of reasons for this, depending on error your solution is different. For example, if you get the following error: - -``` -Captain Starting ... -Installing Captain Service ... -December 18th 2017, 11:51:11.295 pm Starting swarm at 34.232.18.13:2377 -Installation failed. -{ Error: (HTTP code 400) bad parameter - must specify a listening address because the address to advertise is not recognized as a system address, and a system's IP address to use could not be uniquely identified - at /usr/src/app/node_modules/docker-modem/lib/modem.js:254:17 - at getCause (/usr/src/app/node_modules/docker-modem/lib/modem.js:284:7) - at Modem.buildPayload (/usr/src/app/node_modules/docker-modem/lib/modem.js:253:5) - at IncomingMessage. (/usr/src/app/node_modules/docker-modem/lib/modem.js:229:14) - at emitNone (events.js:110:20) - at IncomingMessage.emit (events.js:207:7) - at endReadableNT (_stream_readable.js:1057:12) - at _combinedTickCallback (internal/process/next_tick.js:138:11) - at process._tickCallback (internal/process/next_tick.js:180:9) - reason: 'bad parameter', - statusCode: 400, - json: - { message: 'must specify a listening address because the address to advertise is not recognized as a system address, and a system\'s IP address to use could not be uniquely identified' } } -``` -You can try this: - -``` -docker run -e "MAIN_NODE_IP_ADDRESS=192.168.1.2" -v /var/run/docker.sock:/var/run/docker.sock dockersaturn/captainduckduck -``` - -and replace `192.168.1.2` with your own local IP. - - -### How to view my application's log? +## How to view my application's log? Your application is deployed as a Docker service. For example, if your app name in captain is `my-app` you can view your logs by connecting to your server via SSH and run the following command: ``` docker service logs srv-captain--my-app --since 60m --follow @@ -66,13 +44,10 @@ docker service logs srv-captain--my-app --since 60m --follow Note that Docker service name is prefixed with `srv-captain--`. Also, you can replace 60m with 10m to view last 10 minutes. -### How to restart my application? -If your application is not behaving well, you can try force restarting CaptainDuckDuck using: -``` -docker service update srv-captain--my-app --force -``` +## How to restart my application? +If your application is not behaving well, you can try force restarting it by going to the web dashboard and select your app, then click on "Save Configuration & Update" button. It will forcefully restarts your application. -### How to restart CaptainDuckDuck +## How to restart CaptainDuckDuck If your CaptainDuckDuck is not behaving well, you can try force restarting CaptainDuckDuck using: ``` docker service update captain-captain --force @@ -80,7 +55,7 @@ docker service update captain-captain --force Alternatively, you can go to CaptainDuckDuck dashboard, select your app, without changing anything, simply click on SAVE AND UPDATE CONFIGURATIONS button at the bottom of the page. This will force restart your app. -### How to stop and remove Captain? +## How to stop and remove Captain? Captain uses docker swarm to support clustering and restarting containers if they stop. That's why it keeps re-appearing. Try this: `docker service rm $(docker service ls -q)` diff --git a/website/i18n/en.json b/website/i18n/en.json index c6e1ca4..ba87067 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -6,31 +6,43 @@ "tagline": "Build your own PaaS in a few minutes!", "app-configuration": "App Configuration", "App Configuration": "App Configuration", + "app-scaling-and-cluster": "App Scaling & Cluster", + "App Scaling & Cluster": "App Scaling & Cluster", "captain-definition-file": "Captain Definition File", "Captain Definition File": "Captain Definition File", + "complete-webapp-tutorial": "Complete Webapp Tutorial", + "Complete Webapp Tutorial": "Complete Webapp Tutorial", + "deployment-methods": "Deployment Methods", + "Deployment Methods": "Deployment Methods", + "disk-cleanup": "Disk Clean-Up", + "Disk Clean-Up": "Disk Clean-Up", + "enabling-https": "Enabling HTTPS", + "Enabling HTTPS": "Enabling HTTPS", "doc2": "document number 2", + "Home": "Home", + "firewall": "Firewall & Port Forwarding", + "Firewall & Port Forwarding": "Firewall & Port Forwarding", "get-started": "Get Started", "Get Started": "Get Started", + "nginx-customization": "NGINX Config", + "NGINX Config": "NGINX Config", + "one-click-apps": "One-Click Apps", + "One-Click Apps": "One-Click Apps", + "pre-deploy-script": "Pre-deploy Script", + "Pre-deploy Script": "Pre-deploy Script", + "resource-monitoring": "Resource Monitoring", + "Resource Monitoring": "Resource Monitoring", + "run-locally": "Run Locally", + "Run Locally": "Run Locally", "server-purchase": "Server & Public IP address", "Server Purchase": "Server Purchase", - "Complete-Webapp-Tutorial": "Complete-Webapp-Tutorial", - "Deployment-Methods": "Deployment-Methods", - "Disk-Clean-Up": "Disk-Clean-Up", - "Firewall": "Firewall", - "Home": "Home", - "HTTPS-for-Captain-and-Apps": "HTTPS-for-Captain-and-Apps", - "Monitoring": "Monitoring", - "NGINX-Customization": "NGINX-Customization", - "One-Click-Apps": "One-Click-Apps", - "Run-Locally": "Run-Locally", - "Server-Clustering-and-App-Scaling": "Server-Clustering-and-App-Scaling", + "troubleshooting": "Troubleshooting", "Troubleshooting": "Troubleshooting", "Docs": "Docs", "GitHub": "GitHub", "Basics": "Basics", - "Details": "Details", - "Help": "Help", - "First Category": "First Category" + "Do More": "Do More", + "Help": "Help" }, "pages-strings": { "Help Translate|recruit community translators for your project": "Help Translate", diff --git a/website/sidebars.json b/website/sidebars.json index a08ca40..9a718c3 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -1,12 +1,26 @@ { "docs": { - "Basics": ["get-started"], - "Details":[ + "Basics": [ + "get-started", + "captain-definition-file", + "deployment-methods", "app-configuration", - "captain-definition-file" + "complete-webapp-tutorial" ], - "Help":[ - "server-purchase" + "Do More": [ + "enabling-https", + "one-click-apps", + "resource-monitoring", + "nginx-customization", + "app-scaling-and-cluster", + "pre-deploy-script", + "run-locally" + ], + "Help": [ + "server-purchase", + "disk-cleanup", + "firewall", + "troubleshooting" ] } }