{"id":35039,"date":"2024-10-17T11:40:39","date_gmt":"2024-10-17T04:40:39","guid":{"rendered":"http:\/\/jupitek.maudemo.vip\/index.php\/2024\/10\/17\/deploy-a-flask-application-with-dokku\/"},"modified":"2024-10-17T11:40:39","modified_gmt":"2024-10-17T04:40:39","slug":"deploy-a-flask-application-with-dokku","status":"publish","type":"post","link":"https:\/\/jupitek.maudemo.vip\/index.php\/2024\/10\/17\/deploy-a-flask-application-with-dokku\/","title":{"rendered":"Tri\u1ec3n khai \u1ee9ng d\u1ee5ng Flask v\u1edbi Dokku"},"content":{"rendered":"<p>Dokku l\u00e0 N\u1ec1n t\u1ea3ng d\u01b0\u1edbi d\u1ea1ng d\u1ecbch v\u1ee5 (PaaS) t\u1ef1 l\u01b0u tr\u1eef gi\u00fap tri\u1ec3n khai \u1ee9ng d\u1ee5ng \u0111\u01a1n gi\u1ea3n b\u1eb1ng Git. M\u1eb7c d\u00f9 tri\u1ec3n khai Dokku t\u01b0\u01a1ng t\u1ef1 nh\u01b0 Heroku, nh\u01b0ng n\u00f3 thi\u1ebfu m\u1ed9t s\u1ed1 t\u00ednh n\u0103ng ch\u00ednh nh\u01b0 t\u1ef1 \u0111\u1ed9ng m\u1edf r\u1ed9ng quy m\u00f4. Dokku l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 c\u1ef1c k\u1ef3 m\u1ea1nh m\u1ebd t\u1ef1 \u0111\u1ed9ng ch\u1ea1y \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n b\u00ean trong Docker v\u00e0 y\u00eau c\u1ea7u c\u1ea5u h\u00ecnh t\u1ed1i thi\u1ec3u c\u1ee7a m\u00e1y ch\u1ee7 web.<\/p>\n<p>H\u01b0\u1edbng d\u1eabn n\u00e0y tr\u00ecnh b\u00e0y c\u00e1ch th\u1ef1c hi\u1ec7n:<\/p>\n<ul>\n<li>T\u1ea1o m\u1ed9t \u1ee9ng d\u1ee5ng Flask tr\u1ea3 v\u1ec1 &#8216;Hello World!&#8217; tr\u00ean trang ch\u1ec9 m\u1ee5c<\/li>\n<li>C\u00e0i \u0111\u1eb7t Dokku tr\u00ean Linode<\/li>\n<li>Tri\u1ec3n khai \u1ee9ng d\u1ee5ng Flask v\u1edbi m\u00e1y ch\u1ee7 WSGI b\u00ean trong v\u00f9ng ch\u1ee9a Docker<\/li>\n<li>Th\u00eam ch\u1ee9ng ch\u1ec9 SSL th\u00f4ng qua Dokku b\u1eb1ng plugin Let&#8217;s Encrypt<\/li>\n<\/ul>\n<h2 id=\"before-you-begin\">Tr\u01b0\u1edbc khi b\u1ea1n b\u1eaft \u0111\u1ea7u<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#before-you-begin\"><\/a><\/h2>\n<h3 id=\"on-your-local-computer\">Tr\u00ean m\u00e1y t\u00ednh c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n<\/h3>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: Dokku v0.12.5 t\u01b0\u01a1ng th\u00edch v\u1edbi Ubuntu 16.04 x64, Ubuntu 14.04 x64 v\u00e0 Debian 8.2 x64. CentOS 7 x64 ch\u1ec9 \u0111\u01b0\u1ee3c h\u1ed7 tr\u1ee3 th\u1eed nghi\u1ec7m v\u00e0 do \u0111\u00f3 m\u1ed9t s\u1ed1 b\u01b0\u1edbc nh\u01b0 c\u1ea5u h\u00ecnh kh\u00f3a SSH v\u00e0 m\u00e1y ch\u1ee7 \u1ea3o ph\u1ea3i \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n th\u1ee7 c\u00f4ng b\u1eb1ng giao di\u1ec7n d\u00f2ng l\u1ec7nh dokku. Xem&nbsp;<a href=\"http:\/\/dokku.viewdocs.io\/dokku~v0.12.5\/getting-started\/installation\/\" target=\"_blank\" rel=\"noreferrer noopener\">t\u00e0i li\u1ec7u ch\u00ednh th\u1ee9c<\/a>&nbsp;\u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin.<\/p>\n<p>Ng\u01b0\u1eddi ta cho r\u1eb1ng&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/use-public-key-authentication-with-ssh\/\">kh\u00f3a c\u00f4ng khai<\/a>&nbsp;c\u00f3 s\u1eb5n. Th\u00f4ng th\u01b0\u1eddng, kh\u00f3a n\u00e0y n\u1eb1m \u1edf&nbsp;<code>~\/home\/username\/.ssh\/id_rsa.pub<\/code>.<\/p>\n<p>C\u00e0i \u0111\u1eb7t Git n\u1ebfu c\u1ea7n:<\/p>\n<pre class=\"wp-block-code\"><code>sudo apt install git\n<\/code><\/pre>\n<h3 id=\"on-your-linode\">Tr\u00ean Linode c\u1ee7a b\u1ea1n<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#on-your-linode\"><\/a><\/h3>\n<p>T\u1eadp l\u1ec7nh c\u00e0i \u0111\u1eb7t Dokku t\u1ea1o&nbsp;<code>dokku<\/code>ng\u01b0\u1eddi d\u00f9ng tr\u00ean h\u1ec7 th\u1ed1ng, c\u00e0i \u0111\u1eb7t Docker v\u00e0 k\u00e9o h\u00ecnh \u1ea3nh c\u00f3 li\u00ean quan.<\/p>\n<p>1.T\u1ea3i xu\u1ed1ng t\u1eadp l\u1ec7nh c\u00e0i \u0111\u1eb7t t\u1eeb Dokku sau \u0111\u00f3 ch\u1ea1y t\u1eadp l\u1ec7nh:<\/p>\n<pre class=\"wp-block-code\"><code>wget https:\/\/raw.githubusercontent.com\/dokku\/dokku\/v0.12.5\/bootstrap.sh\nsudo DOKKU_TAG=v0.12.5 bash bootstrap.sh<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>Preparing to install v0.11.6 from https:\/\/github.com\/dokku\/dokku.git...\nFor dokku to build containers, it is strongly suggested that you have 1024 megabytes or more of free memory\nIf necessary, please consult this document to setup swap: http:\/\/dokku.viewdocs.io\/dokku\/advanced-installation\/#vms-with-less-than-1gb-of-memory\n--&gt; Ensuring we have the proper dependencies\n--&gt; Initial apt-get update\n--&gt; Installing docker\n--&gt; NOTE: Using Linode? Docker may complain about missing AUFS support.\n    You can safely ignore this warning.\n        Installation will continue in 10 seconds.\n...<\/code><\/pre>\n<p>2.\u0110i\u1ec1u h\u01b0\u1edbng \u0111\u1ebfn \u0111\u1ecba ch\u1ec9 IP c\u00f4ng khai c\u1ee7a Linode trong tr\u00ecnh duy\u1ec7t v\u00e0 nh\u1eadp kh\u00f3a c\u00f4ng khai:<img loading=\"lazy\" decoding=\"async\" loading=\"lazy\" width=\"385\" height=\"329\" src=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/dokku-public-key.png\" alt=\"C\u00e0i \u0111\u1eb7t Dokku ban \u0111\u1ea7u\"><\/p>\n<p>Quan tr\u1ecdng: Th\u00eam kh\u00f3a c\u00f4ng khai ngay sau khi ch\u1ea1y t\u1eadp l\u1ec7nh c\u00e0i \u0111\u1eb7t \u0111\u1ec3 tr\u00e1nh ng\u01b0\u1eddi kh\u00e1c th\u00eam kh\u00f3a c\u00f4ng khai v\u00e0o Dokku. \u0110\u1ed1i v\u1edbi c\u00e0i \u0111\u1eb7t kh\u00f4ng gi\u00e1m s\u00e1t, h\u00e3y tham kh\u1ea3o&nbsp;<a href=\"https:\/\/github.com\/dokku\/dokku\/blob\/master\/docs\/getting-started\/advanced-installation.md\" target=\"_blank\" rel=\"noreferrer noopener\">h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t n\u00e2ng cao<\/a>&nbsp;.<\/p>\n<p>3.\u0110\u1ec3 th\u00eam kh\u00f3a SSH b\u1ed5 sung, h\u00e3y chuy\u1ec3n \u0111\u1ea7u ra qua SSH \u0111\u1ebfn&nbsp;<code>dokku<\/code>ng\u01b0\u1eddi d\u00f9ng. Thay th\u1ebf&nbsp;<code>example.com<\/code>b\u1eb1ng \u0111\u1ecba ch\u1ec9 IP c\u1ee7a Linode c\u1ee7a b\u1ea1n.<\/p>\n<pre class=\"wp-block-code\"><code>cat ~\/.ssh\/id_rsa.pub | ssh dokku@example.com ssh-keys:add new-key\n<\/code><\/pre>\n<h2 id=\"create-a-flask-application\">T\u1ea1o \u1ee9ng d\u1ee5ng Flask<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#create-a-flask-application\"><\/a><\/h2>\n<p>1.Tr\u00ean m\u00e1y t\u00ednh c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n, h\u00e3y t\u1ea1o m\u1ed9t th\u01b0 m\u1ee5c d\u1ef1 \u00e1n m\u1edbi:<\/p>\n<pre class=\"wp-block-code\"><code>mkdir flask-example &amp;&amp; cd flask-example\n<\/code><\/pre>\n<p>2.T\u1ea1o m\u1ed9t t\u1ec7p m\u1edbi c\u00f3 t\u00ean l\u00e0&nbsp;<code>hello_world.py<\/code>&#8216;Hello World!&#8217; tr\u00ean trang ch\u1ec9 m\u1ee5c.<\/p>\n<pre class=\"wp-block-code\"><code>import os\n\nfrom flask import Flask\n\napp = Flask(__name__)\n\n@app.route('\/')\ndef hello():\n    return 'Hello World!'\n\nif __name__ == '__main__':\n    # Bind to PORT if defined, otherwise default to 5000.\n    port = int(os.environ.get('PORT', 5000))\n    app.run(host='127.0.0.1', port=port)<\/code><\/pre>\n<p>3.Th\u00eam&nbsp;<code>requirements.txt<\/code>t\u1ec7p \u0111\u1ec3 theo d\u00f5i phi\u00ean b\u1ea3n c\u1ee7a b\u1ea5t k\u1ef3 ph\u1ee5 thu\u1ed9c n\u00e0o c\u1ee7a \u1ee9ng d\u1ee5ng Flask. Gunicorn l\u00e0 m\u00e1y ch\u1ee7 WSGI \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 cho ph\u00e9p Flask giao ti\u1ebfp \u0111\u00fang c\u00e1ch v\u1edbi NGINX.<\/p>\n<pre class=\"wp-block-code\"><code>Flask==0.12.1\ngunicorn==19.7.1<\/code><\/pre>\n<p>4.\u0110\u1ed1i v\u1edbi c\u00e1c d\u1ef1 \u00e1n ph\u1ee9c t\u1ea1p h\u01a1n c\u00f3 nhi\u1ec1u s\u1ef1 ph\u1ee5 thu\u1ed9c khi s\u1eed d\u1ee5ng m\u00f4i tr\u01b0\u1eddng \u1ea3o, h\u00e3y chuy\u1ec3n h\u01b0\u1edbng \u0111\u1ea7u ra c\u1ee7a&nbsp;<code>pip freeze<\/code>v\u00e0o&nbsp;<code>requirements.txt<\/code>.<\/p>\n<pre class=\"wp-block-code\"><code>pip freeze &gt; requirements.txt\n<\/code><\/pre>\n<h3 id=\"add-a-gitignore\">Th\u00eam gitignore<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#add-a-gitignore\"><\/a><\/h3>\n<p>T\u00f9y ch\u1ecdn, th\u00eam m\u1ed9t&nbsp;<code>.gitignore<\/code>t\u1ec7p \u0111\u1ec3 Git b\u1ecf qua c\u00e1c t\u1ec7p b\u1ed9 nh\u1edb \u0111\u1ec7m v\u00e0 m\u00f4i tr\u01b0\u1eddng \u1ea3o kh\u1ecfi ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n.<\/p>\n<pre class=\"wp-block-code\"><code>__pycache__\/\n*.pyc\n\nvenv\/<\/code><\/pre>\n<h3 id=\"procfile\">H\u1ed3 s\u01a1<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#procfile\"><\/a><\/h3>\n<p>Procfile cho m\u00e1y ch\u1ee7 Gunicorn bi\u1ebft l\u1ec7nh n\u00e0o c\u1ea7n s\u1eed d\u1ee5ng khi kh\u1edfi ch\u1ea1y \u1ee9ng d\u1ee5ng:<\/p>\n<pre class=\"wp-block-code\"><code>web: gunicorn hello_world:app --workers=4\n<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: 4 c\u00f4ng nh\u00e2n l\u00e0 m\u1eb7c \u0111\u1ecbnh t\u1ed1t cho \u1ee9ng d\u1ee5ng web ch\u1ea1y tr\u00ean Linode. Xem&nbsp;<a href=\"http:\/\/docs.gunicorn.org\/en\/stable\/design.html#how-many-workers\" target=\"_blank\" rel=\"noreferrer noopener\">t\u00e0i li\u1ec7u Gunicorn<\/a>&nbsp;\u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 c\u00e1ch x\u00e1c \u0111\u1ecbnh s\u1ed1 l\u01b0\u1ee3ng c\u00f4ng nh\u00e2n ch\u00ednh x\u00e1c cho \u1ee9ng d\u1ee5ng c\u1ee5 th\u1ec3 c\u1ee7a b\u1ea1n.<\/p>\n<h3 id=\"git-remote\">Git t\u1eeb xa<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#git-remote\"><\/a><\/h3>\n<p>1.Kh\u1edfi t\u1ea1o kho l\u01b0u tr\u1eef Git:<\/p>\n<pre class=\"wp-block-code\"><code>git init\ngit add .\ngit commit -m \"Deploy Flask with Dokku\"<\/code><\/pre>\n<p>2.Th\u00eam m\u1ed9t t\u00ean mi\u1ec1n t\u1eeb xa&nbsp;<code>dokku<\/code>c\u00f3 t\u00ean ng\u01b0\u1eddi d\u00f9ng&nbsp;<code>dokku<\/code>v\u00e0 thay th\u1ebf&nbsp;<code>example.com<\/code>b\u1eb1ng \u0111\u1ecba ch\u1ec9 IP c\u00f4ng khai c\u1ee7a Linode c\u1ee7a b\u1ea1n:<\/p>\n<pre class=\"wp-block-code\"><code>git remote add dokku dokku@example.com:flask-example\n<\/code><\/pre>\n<p>3.X\u00e1c minh \u0111i\u1ec1u khi\u1ec3n t\u1eeb xa \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o:<\/p>\n<pre class=\"wp-block-code\"><code>git remote -v\n<\/code><\/pre>\n<p>Thao t\u00e1c n\u00e0y s\u1ebd li\u1ec7t k\u00ea c\u00e1c \u0111i\u1ec1u khi\u1ec3n t\u1eeb xa.<\/p>\n<pre class=\"wp-block-code\"><code>dokku   dokku@example-ip:flask-example (fetch)\ndokku   dokku@example-ip:flask-example (push)<\/code><\/pre>\n<p>T\u00f3m l\u1ea1i, b\u1ed1 c\u1ee5c c\u1ee7a d\u1ef1 \u00e1n tr\u00f4ng nh\u01b0 th\u1ebf n\u00e0y:<\/p>\n<pre class=\"wp-block-code\"><code>flask-example\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 Procfile\n\u251c\u2500\u2500 hello_world.py\n\u2514\u2500\u2500 requirements.txt<\/code><\/pre>\n<h2 id=\"create-project-on-a-dokku-host\">T\u1ea1o d\u1ef1 \u00e1n tr\u00ean m\u00e1y ch\u1ee7 Dokku<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#create-project-on-a-dokku-host\"><\/a><\/h2>\n<p>1.SSH v\u00e0o Linode c\u1ee7a b\u1ea1n v\u00e0 t\u1ea1o \u1ee9ng d\u1ee5ng:<\/p>\n<pre class=\"wp-block-code\"><code>dokku apps:create flask-example\n<\/code><\/pre>\n<p>2.\u0110\u1ea3m b\u1ea3o VHOST \u0111\u00e3 \u0111\u01b0\u1ee3c b\u1eadt.<\/p>\n<pre class=\"wp-block-code\"><code>dokku domains:enable flask-example\n<\/code><\/pre>\n<h2 id=\"deploy-a-flask-application\">Tri\u1ec3n khai \u1ee9ng d\u1ee5ng Flask<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#deploy-a-flask-application\"><\/a><\/h2>\n<p>1.Tr\u00ean m\u00e1y t\u00ednh c\u1ee5c b\u1ed9 c\u1ee7a b\u1ea1n, tri\u1ec3n khai \u1ee9ng d\u1ee5ng Flask b\u1eb1ng c\u00e1ch \u0111\u1ea9y nh\u00e1nh l\u00ean&nbsp;<code>dokku<\/code>m\u00e1y ch\u1ee7 t\u1eeb xa. Thao t\u00e1c n\u00e0y s\u1ebd x\u1eed l\u00fd NGINX \u1edf ch\u1ebf \u0111\u1ed9 n\u1ec1n v\u00e0 hi\u1ec3n th\u1ecb c\u1ed5ng&nbsp;<code>80<\/code>:<\/p>\n<pre class=\"wp-block-code\"><code>git push dokku master\n<\/code><\/pre>\n<p>C\u00e1c nh\u00e1nh c\u1ee5c b\u1ed9 kh\u00e1c c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c tri\u1ec3n khai nh\u01b0ng t\u1ea5t c\u1ea3 c\u00e1c nh\u00e1nh ph\u1ea3i \u0111\u01b0\u1ee3c \u0111\u1ea9y l\u00ean nh\u00e1nh ch\u00ednh c\u1ee7a nh\u00e1nh&nbsp;<code>dokku<\/code>t\u1eeb xa:<\/p>\n<pre class=\"wp-block-code\"><code>git push dokku branch-name:master<\/code><\/pre>\n<p>2.<code>curl<\/code>\u0111\u1ecba ch\u1ec9 IP c\u1ee7a Linode \u0111\u1ec3 ki\u1ec3m tra xem \u1ee9ng d\u1ee5ng \u0111\u00e3 \u0111\u01b0\u1ee3c tri\u1ec3n khai th\u00e0nh c\u00f4ng hay ch\u01b0a:<\/p>\n<pre class=\"wp-block-code\"><code>curl example.com<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>Hello World!\n<\/code><\/pre>\n<h3 id=\"ssl-certificate-with-dokku-and-lets-encrypt\">Ch\u1ee9ng ch\u1ec9 SSL v\u1edbi Dokku v\u00e0 Let&#8217;s Encrypt<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#ssl-certificate-with-dokku-and-lets-encrypt\"><\/a><\/h3>\n<p>C\u00e1c b\u01b0\u1edbc c\u00f2n l\u1ea1i trong h\u01b0\u1edbng d\u1eabn n\u00e0y ph\u1ea3i \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n t\u1eeb Linode c\u1ee7a b\u1ea1n.<\/p>\n<p>1.C\u00e0i \u0111\u1eb7t plugin Let&#8217;s Encrypt cho Dokku:<\/p>\n<pre class=\"wp-block-code\"><code>sudo dokku plugin:install https:\/\/github.com\/dokku\/dokku-letsencrypt.git\n<\/code><\/pre>\n<p>2.\u0110\u1eb7t&nbsp;<code>DOKKU_LETSENCRYPT_EMAIL<\/code>bi\u1ebfn m\u00f4i tr\u01b0\u1eddng th\u00e0nh email cho Let&#8217;s Encrypt:<\/p>\n<pre class=\"wp-block-code\"><code>dokku config:set flask-example DOKKU_LETSENCRYPT_EMAIL=docs@linode.com\n<\/code><\/pre>\n<p>3.Th\u00eam \u1ee9ng d\u1ee5ng v\u00e0 t\u00ean mi\u1ec1n:<\/p>\n<pre class=\"wp-block-code\"><code>dokku domains:add flask-example example.com\n<\/code><\/pre>\n<p>4.T\u1ea1o ch\u1ee9ng ch\u1ec9 SSL. NGINX s\u1ebd t\u1ef1 \u0111\u1ed9ng b\u1eaft \u0111\u1ea7u ph\u1ee5c v\u1ee5 \u1ee9ng d\u1ee5ng qua HTTPS tr\u00ean c\u1ed5ng 443:<\/p>\n<pre class=\"wp-block-code\"><code>dokku letsencrypt flask-example\n<\/code><\/pre>\n<p>5.Ch\u1ea1y l\u1ec7nh n\u00e0y nh\u01b0 m\u1ed9t t\u00e1c v\u1ee5 cron \u0111\u1ec3 ch\u1ee9ng ch\u1ec9 t\u1ef1 \u0111\u1ed9ng gia h\u1ea1n:.<\/p>\n<pre class=\"wp-block-code\"><code>dokku letsencrypt:cron-job --add<\/code><\/pre>\n<h2 id=\"start-stop-and-restart-applications\">B\u1eaft \u0111\u1ea7u, d\u1eebng v\u00e0 kh\u1edfi \u0111\u1ed9ng l\u1ea1i \u1ee9ng d\u1ee5ng<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#start-stop-and-restart-applications\"><\/a><\/h2>\n<ul>\n<li>Li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c \u1ee9ng d\u1ee5ng Dokku \u0111ang ch\u1ea1y:<code> dokku apps<\/code><\/li>\n<li>Kh\u1edfi \u0111\u1ed9ng l\u1ea1i \u1ee9ng d\u1ee5ng:<code> dokku ps:restart flask-example<\/code><\/li>\n<li>D\u1eebng m\u1ed9t \u1ee9ng d\u1ee5ng:<code> dokku ps:stop flask-example<\/code><\/li>\n<li>Kh\u00f4i ph\u1ee5c t\u1ea5t c\u1ea3 c\u00e1c \u1ee9ng d\u1ee5ng sau khi kh\u1edfi \u0111\u1ed9ng l\u1ea1i:<code> dokku ps:restore<\/code><\/li>\n<\/ul>\n<h3 id=\"view-application-logs\">Xem Nh\u1eadt k\u00fd \u1ee9ng d\u1ee5ng<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#view-application-logs\"><\/a><\/h3>\n<p>Xem nh\u1eadt k\u00fd \u1ee9ng d\u1ee5ng th\u00f4ng qua Dokku ho\u1eb7c container Docker.<\/p>\n<ol>\n<li>\u0110\u1ec3 xem nh\u1eadt k\u00fd th\u00f4ng qua Dokku:<code>dokku logs flask-example<\/code><\/li>\n<li>Li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 c\u00e1c container Docker \u0111ang ch\u1ea1y:<code>sudo docker ps -a<\/code><\/li>\n<li>T\u00ecm ID container sau \u0111\u00f3 ch\u1ea1y:<code>sudo docker logs container_id<\/code><\/li>\n<\/ol>\n<h2 id=\"scale-applications\">\u1ee8ng d\u1ee5ng c\u00e2n<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/#scale-applications\"><\/a><\/h2>\n<p>Dokku kh\u00f4ng t\u1ef1 \u0111\u1ed9ng m\u1edf r\u1ed9ng \u1ee9ng d\u1ee5ng v\u00e0 theo m\u1eb7c \u0111\u1ecbnh s\u1ebd ch\u1ec9 ch\u1ea1y m\u1ed9t&nbsp;<code>web<\/code>quy tr\u00ecnh duy nh\u1ea5t. \u0110\u1ec3 t\u0103ng s\u1ed1 l\u01b0\u1ee3ng container ch\u1ea1y \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng&nbsp;<code>ps:scale<\/code>l\u1ec7nh.<\/p>\n<p>1.Ki\u1ec3m tra xem \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n hi\u1ec7n c\u00f3 bao nhi\u00eau nh\u00e2n vi\u00ean:<\/p>\n<pre class=\"wp-block-code\"><code>dokku ps:scale flask-example\n<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>-----&gt; Scaling for flask-example\n-----&gt; proctype           qty\n-----&gt; --------           ---\n-----&gt; web                1<\/code><\/pre>\n<p>2.M\u1edf r\u1ed9ng l\u00ean t\u1edbi 4&nbsp;<code>web<\/code>quy tr\u00ecnh:<\/p>\n<pre class=\"wp-block-code\"><code>dokku ps:scale flask-example web=4\n<\/code><\/pre>\n<p>3.X\u00e1c nh\u1eadn r\u1eb1ng c\u00e1c quy tr\u00ecnh m\u1edbi \u0111ang ch\u1ea1y:<\/p>\n<pre class=\"wp-block-code\"><code>-----&gt; Scaling for flask-example\n-----&gt; proctype           qty\n-----&gt; --------           ---\n-----&gt; web                4<\/code><\/pre>\n<p>Dokku l\u00e0 m\u1ed9t gi\u1ea3i ph\u00e1p thay th\u1ebf m\u00e3 ngu\u1ed3n m\u1edf cho Heroku d\u00e0nh cho c\u00e1c \u1ee9ng d\u1ee5ng nh\u1ecf. Vi\u1ec7c tri\u1ec3n khai c\u00e1c \u1ee9ng d\u1ee5ng c\u0169ng \u0111\u01a1n gi\u1ea3n nh\u01b0 \u0111\u1ea9y l\u00ean m\u1ed9t m\u00e1y ch\u1ee7 t\u1eeb xa b\u1eb1ng Git. C\u00e1c th\u00e0nh ph\u1ea7n nh\u01b0 Docker v\u00e0 NGINX \u0111\u01b0\u1ee3c tr\u1eebu t\u01b0\u1ee3ng h\u00f3a \u0111\u1ec3 gi\u1ea3m thi\u1ec3u th\u1eddi gian tri\u1ec3n khai. C\u00f3 c\u00e1c t\u00ednh n\u0103ng b\u1ed5 sung nh\u01b0&nbsp;<a href=\"http:\/\/dokku.viewdocs.io\/dokku\/advanced-usage\/deployment-tasks\/\" target=\"_blank\" rel=\"noreferrer noopener\">hook tr\u01b0\u1edbc khi tri\u1ec3n khai<\/a>&nbsp;v\u00e0 li\u00ean k\u1ebft c\u01a1 s\u1edf d\u1eef li\u1ec7u kh\u00f4ng \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb trong h\u01b0\u1edbng d\u1eabn n\u00e0y.<\/p>\n<h2 id=\"more-information\">Th\u00f4ng tin th\u00eam<\/h2>\n<p>B\u1ea1n c\u00f3 th\u1ec3 mu\u1ed1n tham kh\u1ea3o c\u00e1c ngu\u1ed3n sau \u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 ch\u1ee7 \u0111\u1ec1 n\u00e0y. M\u1eb7c d\u00f9 ch\u00fang t\u00f4i cung c\u1ea5p v\u1edbi hy v\u1ecdng r\u1eb1ng ch\u00fang s\u1ebd h\u1eefu \u00edch, nh\u01b0ng xin l\u01b0u \u00fd r\u1eb1ng ch\u00fang t\u00f4i kh\u00f4ng th\u1ec3 \u0111\u1ea3m b\u1ea3o t\u00ednh ch\u00ednh x\u00e1c ho\u1eb7c t\u00ednh k\u1ecbp th\u1eddi c\u1ee7a c\u00e1c t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef b\u00ean ngo\u00e0i.<\/p>\n<ul>\n<li><a href=\"http:\/\/dokku.viewdocs.io\/dokku\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dokku PaaS<\/a><\/li>\n<li><a href=\"http:\/\/flask.pocoo.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">B\u00ecnh \u0111\u1ef1ng n\u01b0\u1edbc<\/a><\/li>\n<\/ul>\n<p>Ngu\u1ed3n: https:\/\/www.linode.com\/docs\/guides\/deploy-a-flask-application-with-dokku\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dokku l\u00e0 N\u1ec1n t\u1ea3ng d\u01b0\u1edbi d\u1ea1ng d\u1ecbch v\u1ee5 (PaaS) t\u1ef1 l\u01b0u tr\u1eef gi\u00fap tri\u1ec3n khai \u1ee9ng d\u1ee5ng \u0111\u01a1n gi\u1ea3n b\u1eb1ng Git. M\u1eb7c d\u00f9 tri\u1ec3n khai Dokku t\u01b0\u01a1ng t\u1ef1 nh\u01b0 Heroku, nh\u01b0ng n\u00f3 thi\u1ebfu m\u1ed9t s\u1ed1 t\u00ednh n\u0103ng ch\u00ednh nh\u01b0 t\u1ef1 \u0111\u1ed9ng m\u1edf r\u1ed9ng quy m\u00f4. Dokku l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 c\u1ef1c k\u1ef3 m\u1ea1nh m\u1ebd t\u1ef1<\/p>\n","protected":false},"author":1,"featured_media":36268,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-35039","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-containers"],"_links":{"self":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/35039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/comments?post=35039"}],"version-history":[{"count":0,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/35039\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media\/36268"}],"wp:attachment":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media?parent=35039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/categories?post=35039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/tags?post=35039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}