Now link the db to your dokku app, and it would add a new env varialbe DATABASE_URL to the dokku app. Service root: /var/lib/dokku/services/postgres/django-dokku-example-db => django-dokku-example-db postgres service informationĬonfig dir: /var/lib/dokku/services/postgres/django-dokku-example-db/dataĭata dir: /var/lib/dokku/services/postgres/django-dokku-example-db/data => Postgres container created: django-dokku-example-db $ sudo dokku postgres:create django-dokku-example-db -image "postgres" -image-version "14.1" # we can even use -image-version to specify postgres version Here we put the Postgres db on our server, but you can also use 3-party DB server like Amazon RDS if you like.ĭokku has many plugins and here we use postgres plugin to help us. Create Dokku app $ sudo dokku apps:create django-dokku-example Please note that, the dokku project has name django-dokku-example. Next, let's create and config our Dokku app. SHA256:XXXXXX NAME="admin" SSHCOMMAND_ALLOWED_KEYS="no-agent-forwarding,no-user-rc,no-X11-forwarding,no-port-forwarding" (local)$ cat ~/.ssh/id_ed25519.pub | ssh _server dokku ssh-keys:add admin Setup DokkuĪfter we install Dokku, we will see something like this in the terminal ! Setup a user's ssh key for deployment by passing in the public ssh key as shown:Įcho 'CONTENTS_OF_ID_RSA_PUB_FILE' | sudo dokku ssh-keys:add admin The script would also install dependencies and Dokku on the server. (server)$ sudo DOKKU_TAG=v0.26.5 bash bootstrap.sh Let's SSH to our server and then use code below to install Dokku # Please use ssh to login to your server We can get the install script on the Dokku release page Now we can use ssh dokku_server instead of ssh to login to your server Install Dokku Please add code below to your ~/.ssh/config on local. Now on local, we can login ssh without typing the complex password, which is convenient. Now on local, upload the ssh public key to the vps (local)$ cat ~/.ssh/id_ed25519.pub | ssh "cat > ~/.ssh/authorized_keys" Improve SSH Experience # make sure we login as normal user instad of root Now we can change to new user (root)-# su michaelyin Make sudo without passwd, note that this setting is not recommended if the vps requires more safety (root)-# visudo (root)-# adduser michaelyinĪdd user to sudo group (root)-# usermod -a -G sudo michaelyin id_ed25519 is private key, you should not share it to other people.Īfter we SSH to our server as root, let's create normal user first.If you meet problem, please check Generating a new SSH key to learn more. At the prompt, type a secure passphrase.When you're prompted to "Enter a file in which to save the key," press Enter.If you already have SSH key, you can skip this section. The source code of this post can be found on Github, please give it star if it helps you. How to install, config Dokku app and plugins.How to install Dokku, config Dokku server.In this Dokku tutorial, I will talk about how to deploy Django project with Dokku, it would use Postgres db and Amazon S3 to store data and media files.Īfter reading this tutorial, you will get: You can use it on AWS EC2 or VPS such as Digital Ocean to save your time on many DevOps work. How to deploy Django project to Dokku with Dockerĭokku is a PaaS implementation built on docker, it can give you a Heroku-like environment which is also open source and free.How to monitor Heroku Postgres using heroku-pg-extras.How to deploy Python project to Heroku in Gitlab CI.How to deploy Django project to Heroku using Docker.Heroku vs AWS Which is Best for Your Django project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |