Merge pull request #3506 from vanastassiou/patch-2

Update application-deployment.md
This commit is contained in:
Jose Diaz-Gonzalez
2019-04-22 04:22:11 -04:00
committed by GitHub

View File

@@ -1,11 +1,10 @@
# Deploying to Dokku
> Note: This document uses the hostname `dokku.me` in commands. For your server, please
> substitute your server's hostname instead.
> Note: This walkthrough uses the hostname `dokku.me` in commands. When deploying to your own server, you should set the `DOKKU_DOMAIN` value in the `Vagrantfile` before you initialize the Vagrant VM.
## Deploy tutorial
Once Dokku has been configured with at least one user, applications can be deployed via a `git push` command. To quickly see Dokku deployment in action, you can use the Heroku Ruby on Rails example app.
Once you have configured Dokku with at least one user, you can deploy applications using `git push`. To quickly see Dokku deployment in action, try using [the Heroku Ruby on Rails "Getting Started" app](https://github.com/heroku/ruby-getting-started).
```shell
# from your local machine
@@ -15,7 +14,7 @@ git clone git@github.com:heroku/ruby-getting-started.git
### Create the app
Create the application on the Dokku host. You will need to SSH onto the host to run this command.
SSH into the Dokku host and create the application as follows:
```shell
# on the Dokku host
@@ -24,7 +23,9 @@ dokku apps:create ruby-getting-started
### Create the backing services
When you create a new app, Dokku by default *does not* provide any datastores such as MySQL or PostgreSQL. You will need to install plugins to handle that, but fortunately [Dokku has official plugins](/docs/community/plugins.md#official-plugins-beta) for common datastores. Our sample app requires a PostgreSQL service:
Dokku by default **does not** provide datastores (e.g. MySQL, PostgreSQL) on a newly created app. You can add datastore support by installing plugins, and the Dokku project [provides official plugins](/docs/community/plugins.md#official-plugins-beta) for common datastores.
The Getting Started app requires a PostgreSQL service, so install the plugin and create the related service as follows:
```shell
# on the Dokku host
@@ -36,11 +37,11 @@ sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku postgres:create railsdatabase
```
> Each service may take a few moments to create.
Each service may take a few moments to create.
### Linking backing services to applications
Once the service creation is complete, set the `DATABASE_URL` environment variable by linking the service.
Once the services have been created, you then set the `DATABASE_URL` environment variable by linking the service, as follows:
```shell
# on the Dokku host
@@ -48,12 +49,11 @@ Once the service creation is complete, set the `DATABASE_URL` environment variab
dokku postgres:link railsdatabase ruby-getting-started
```
> You can link a single service to multiple applications or use one service per application.
Dokku supports linking a single service to multiple applications as well as linking only one service per application.
### Deploy the app
> Warning: Your application *should* respect the `PORT` environment variable or it may not respond to web requests.
> Please see the [port management documentation](/docs/networking/port-management.md) for details.
> Warning: Your app should respect the `PORT` environment variable, otherwise it may not respond to web requests. You can find more information in the [port management documentation](/docs/networking/port-management.md).**
Now you can deploy the `ruby-getting-started` app to your Dokku server. All you have to do is add a remote to name the app. Applications are created on-the-fly on the Dokku server.
@@ -69,9 +69,9 @@ git push dokku master
> the upstream with the scheme `ssh://` like so: `ssh://dokku@dokku.me:ruby-getting-started`
> Please see the [Git](https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a) documentation for more details.
> Note: Your private key should be registered with ssh-agent in local development. If you get a
> permission denied error when pushing you can register your private key by running
> `ssh-add -k ~/<your private key>`.
> Note: Your private key should be registered with `ssh-agent` in your local development environment. If you get a `permission denied` error when pushing, you can register your private key as follows: `ssh-add -k ~/<your private key>`.
After running `git push dokku master`, you should have output similar to this in your terminal:
```
Counting objects: 231, done.
@@ -98,9 +98,9 @@ Total 231 (delta 93), reused 147 (delta 53)
http://ruby-getting-started.dokku.me
```
When the deploy finishes, the application's URL will be shown as seen above.
Once the deploy is complete, the application's web URL will be generated as above.
Dokku supports deploying applications via [Heroku buildpacks](https://devcenter.heroku.com/articles/buildpacks) with [Herokuish](https://github.com/gliderlabs/herokuish#buildpacks) or using a project's [Dockerfile](https://docs.docker.com/reference/builder/).
Dokku supports deploying applications via [Heroku buildpacks](https://devcenter.heroku.com/articles/buildpacks) with [Herokuish](https://github.com/gliderlabs/herokuish#buildpacks), as well as by using a project's [Dockerfile](https://docs.docker.com/reference/builder/).
### Skipping deployment
@@ -114,7 +114,7 @@ dokku config:set ruby-getting-started DOKKU_SKIP_DEPLOY=true
### Redeploying or restarting
If you need to redeploy (or restart) your app:
If you need to redeploy or restart your app:
```shell
# on the Dokku host
@@ -123,9 +123,9 @@ dokku ps:rebuild ruby-getting-started
See the [process scaling documentation](/docs/deployment/process-management.md) for more information.
### Deploying with private git submodules
### Deploying with private Git submodules
Dokku uses Git locally (i.e. not a Docker image) to build its own copy of your app repo, including submodules. This is done as the `dokku` user. Therefore, in order to deploy private Git submodules, you'll need to drop your deploy key in `/home/dokku/.ssh/` and potentially add `github.com` (or your VCS host key) into `/home/dokku/.ssh/known_hosts`. The following test should help confirm you've done it correctly.
Dokku uses Git locally (i.e. not a Docker image) to build its own copy of your app repo, including submodules, as the `dokku` user. This means that in order to deploy private Git submodules, you need to put your deploy key in `/home/dokku/.ssh/` and potentially add `github.com` (or your VCS host key) into `/home/dokku/.ssh/known_hosts`. You can use the following test to confirm your setup is correct:
```shell
# on the Dokku host
@@ -134,11 +134,11 @@ ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
ssh -T git@github.com
```
Note that if the buildpack or Dockerfile build process require SSH key access for other reasons, the above may not always apply.
> Warning: if the buildpack or Dockerfile build process require SSH key access for other reasons, the above may not always apply.
## Deploying to subdomains
The name of remote repository is used as the name of application to be deployed, as for example above:
If you do not enter a fully qualified domain name when pushing your app, Dokku deploys the app to `<remotename>.yourdomain.tld` as follows:
```shell
# from your local machine
@@ -152,7 +152,7 @@ remote: -----> Application deployed:
remote: http://ruby-getting-started.dokku.me
```
You can also specify fully qualified names, say `app.dokku.me`, as
You can also specify the fully qualified name as follows:
```shell
# from your local machine
@@ -166,7 +166,7 @@ remote: -----> Application deployed:
remote: http://app.dokku.me
```
This is in particular useful, then you want to deploy to root domain, as
This is useful when you want to deploy to the root domain:
```shell
# from your local machine
@@ -182,9 +182,9 @@ git push dokku master
## Dokku/Docker container management compatibility
Dokku is, at its core, a Docker container manager. Thus, it does not necessarily play well with other out-of-band processes interacting with the Docker daemon. One thing to note as in [issue #1220](https://github.com/dokku/dokku/issues/1220), Dokku executes a cleanup function prior to every deployment.
Dokku is, at its core, a Docker container manager. Thus, it does not necessarily play well with other out-of-band processes interacting with the Docker daemon.
As of 0.5.x, this function removes all containers with the label `dokku` where the status is either `dead` or `exited`, as well as all `dangling` images. Previous versions would remove `dead` or `exited` containers, regardless of their label.
Prior to every deployment, Dokku will execute a cleanup function. As of 0.5.x, the cleanup removes all containers with the `dokku` label where the status is either `dead` or `exited` (previous versions would remove _all_ `dead` or `exited` containers). The cleanup function also removes all images with `dangling` status.
## Adding deploy users