-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1ae22b
commit 86656e7
Showing
3 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,112 @@ | |
|
||
/* Code blok */div#\:\$p>svg>foreignObject>section .hljs-bullet{color:var(--text)}div#\:\$p>svg>foreignObject>section .hljs-comment{color:var(--muted)}div#\:\$p>svg>foreignObject>section .hljs-attr{color:var(--foam)}div#\:\$p>svg>foreignObject>section .hljs-punctuation{color:var(--subtle)}div#\:\$p>svg>foreignObject>section .hljs-string{color:var(--gold)}div#\:\$p>svg>foreignObject>section .hljs-title{color:var(--foam)}div#\:\$p>svg>foreignObject>section .hljs-keyword{color:var(--pine)}div#\:\$p>svg>foreignObject>section .hljs-variable{color:var(--text)}div#\:\$p>svg>foreignObject>section .hljs-literal{color:var(--rose)}div#\:\$p>svg>foreignObject>section .hljs-type{color:var(--love)}div#\:\$p>svg>foreignObject>section .hljs-number{color:var(--gold)}div#\:\$p>svg>foreignObject>section .hljs-built_in{color:var(--love)}div#\:\$p>svg>foreignObject>section .hljs-params{color:var(--iris)}div#\:\$p>svg>foreignObject>section .hljs-symbol{color:var(--foam)}div#\:\$p>svg>foreignObject>section .hljs-meta{color:var(--subtle)}div#\:\$p>svg>foreignObject>section .hljs-subst{color:var(--subtle)}div#\:\$p>svg>foreignObject>section blockquote{font-size:20px}div#\:\$p>svg>foreignObject>section blockquote p{font-size:20px}div#\:\$p>svg>foreignObject>section blockquote p a{font-size:30px}div#\:\$p>svg>foreignObject>section div.mermaid{text-align:center}div#\:\$p>svg>foreignObject>section img[alt~=center]{display:block;margin:0 auto}div#\:\$p>svg>foreignObject>section .columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:calc(var(--marpit-root-font-size, 1rem) * 1)} | ||
|
||
/* @theme wocl7k64ubdnkd9hydgr59hqpqgsr88lmmwx2wj7t7lh */div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]{columns:initial!important;display:block!important;padding:0!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:before,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:before{display:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]{all:initial;display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container][data-marpit-advanced-background-direction=vertical]{flex-direction:column}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split]>div[data-marpit-advanced-background-container]{width:var(--marpit-advanced-background-split,50%)}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split=right]>div[data-marpit-advanced-background-container]{margin-left:calc(100% - var(--marpit-advanced-background-split, 50%))}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure{all:initial;background-position:center;background-repeat:no-repeat;background-size:cover;flex:auto;margin:0}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure>figcaption{position:absolute;border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content],div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo]{background:transparent!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo],div#\:\$p>svg[data-marpit-svg]>foreignObject[data-marpit-advanced-background=pseudo]{pointer-events:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background-split]{width:100%;height:100%}</style></head><body><div class="bespoke-marp-osc"><button data-bespoke-marp-osc="prev" tabindex="-1" title="Previous slide">Previous slide</button><span data-bespoke-marp-osc="page"></span><button data-bespoke-marp-osc="next" tabindex="-1" title="Next slide">Next slide</button><button data-bespoke-marp-osc="fullscreen" tabindex="-1" title="Toggle fullscreen (f)">Toggle fullscreen</button><button data-bespoke-marp-osc="presenter" tabindex="-1" title="Open presenter view (p)">Open presenter view</button></div><div id=":$p"><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="1" data-theme="wocl7k64ubdnkd9hydgr59hqpqgsr88lmmwx2wj7t7lh" lang="en-US" style="--theme:wocl7k64ubdnkd9hydgr59hqpqgsr88lmmwx2wj7t7lh;"> | ||
/* @theme cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h */div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]{columns:initial!important;display:block!important;padding:0!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:before,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:before{display:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]{all:initial;display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container][data-marpit-advanced-background-direction=vertical]{flex-direction:column}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split]>div[data-marpit-advanced-background-container]{width:var(--marpit-advanced-background-split,50%)}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split=right]>div[data-marpit-advanced-background-container]{margin-left:calc(100% - var(--marpit-advanced-background-split, 50%))}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure{all:initial;background-position:center;background-repeat:no-repeat;background-size:cover;flex:auto;margin:0}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure>figcaption{position:absolute;border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content],div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo]{background:transparent!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo],div#\:\$p>svg[data-marpit-svg]>foreignObject[data-marpit-advanced-background=pseudo]{pointer-events:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background-split]{width:100%;height:100%}</style></head><body><div class="bespoke-marp-osc"><button data-bespoke-marp-osc="prev" tabindex="-1" title="Previous slide">Previous slide</button><span data-bespoke-marp-osc="page"></span><button data-bespoke-marp-osc="next" tabindex="-1" title="Next slide">Next slide</button><button data-bespoke-marp-osc="fullscreen" tabindex="-1" title="Toggle fullscreen (f)">Toggle fullscreen</button><button data-bespoke-marp-osc="presenter" tabindex="-1" title="Open presenter view (p)">Open presenter view</button></div><div id=":$p"><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="1" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h1 id="fazendo-deploy-no-flyio">Fazendo deploy no Fly.io</h1> | ||
<blockquote> | ||
<p><a href="https://fastapidozero.dunossauro.com/12/">https://fastapidozero.dunossauro.com/12/</a></p> | ||
</blockquote> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="2" data-theme="wocl7k64ubdnkd9hydgr59hqpqgsr88lmmwx2wj7t7lh" lang="en-US" style="--theme:wocl7k64ubdnkd9hydgr59hqpqgsr88lmmwx2wj7t7lh;"> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="2" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="objetivos-dessa-aula">Objetivos dessa aula</h2> | ||
<ul> | ||
<li>Entender o que é o Fly.io e como usar sua CLI</li> | ||
<li>Aprender a fazer o deploy de uma aplicação Docker no Fly.io</li> | ||
<li>Configurar uma instância do PostgreSQL no Fly.io</li> | ||
<li>Configurar as variáveis de ambiente</li> | ||
<li>Rodar as migrações em produção</li> | ||
</ul> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="3" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="deploy">Deploy</h2> | ||
<p>A ultima parte do processo do código, <strong>colocar em produção</strong>.</p> | ||
<p>No caso da nossa API, é "soltar ela no mundo" para que as outras pessoas usar. Liberar na internet.</p> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="4" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="flyio">Fly.io</h2> | ||
<p>O Fly.io é uma plataforma de deploy que nos permite fazer o lançamento nossas aplicações na nuvem e que oferece serviços para diversas linguagens de programação e frameworks como Python e Django, PHP e Laravel, Ruby e Rails, Elixir e Phoenix, etc.</p> | ||
<p>Ao mesmo tempo, em que permite que o deploy de aplicações em containers docker também possam ser utilizadas, como é o nosso caso. Além disso, o Fly disponibiliza bancos de dados para serem usados em nossas aplicações, como PostgreSQL e Redis.</p> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="5" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="mas-flyio">Mas, Fly.io?</h2> | ||
<p>A ideia de usar o fly.io é que ele oferece uma plataforma simplificada para deploy. Sendo necessário nos preocuparmos somente o container Docker da nossa aplicação.</p> | ||
<p>O restante das configurações fica a encargo deles.</p> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="6" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="paas---platform-as-a-service">PaaS - Platform as a service</h2> | ||
<p>Uma plataforma como serviço significa que contratamos um serviço de plataforma.</p> | ||
<p>Por plataforma entenda que o serviço contratado vai cuidar de:</p> | ||
<ul> | ||
<li>Segurança</li> | ||
<li>Rede</li> | ||
<li>Disponibilidade</li> | ||
<li>Atualizações / Manutenção</li> | ||
<li>...</li> | ||
</ul> | ||
<p>Entregamos container ao serviço e damos "play"</p> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="7" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="uma-not%C3%ADcia-incr%C3%ADvel-3">Uma notícia incrível <3</h2> | ||
<p>Temos um cumpom de crédito para usar o fly:<br /> | ||
<a href="https://fly.io/fastapi-do-zero-2024">https://fly.io/fastapi-do-zero-2024</a></p> | ||
<p>Obrigado de mais Kátia Nakamura <3 <3 <3</p> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="8" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="flyctl">Flyctl</h2> | ||
<p>O flyctl é um CLI do fly que podemos usar para fazer as funções administrativas da aplicação pelo terminal:</p> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">flyctl version | ||
</code></pre> | ||
<blockquote> | ||
<p>Caso precise instalar o <a href="https://fly.io/docs/flyctl/">flyctl</a></p> | ||
</blockquote> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="9" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="autentica%C3%A7%C3%A3o-via-cli">Autenticação via CLI</h2> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">flyctl auth login | ||
</code></pre> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="10" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="configura%C3%A7%C3%A3o-para-o-deploy">Configuração para o deploy</h2> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">flyctl launch --no-deploy | ||
</code></pre> | ||
<p>Responda um absoluto Y aqui:</p> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash"><span class="hljs-comment"># ...</span> | ||
? Do you want to tweak these settings before proceeding? (y/N) | ||
</code></pre> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="11" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="manuzeando-nossa-vari%C3%A1veis-de-ambiente">Manuzeando nossa variáveis de ambiente</h2> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">flyctl secrets list | ||
flyctl secrets <span class="hljs-built_in">set</span> DATABASE_URL=??? | ||
flyctl secrets <span class="hljs-built_in">set</span> ALGORITHM=<span class="hljs-string">"HS256"</span> | ||
flyctl secrets <span class="hljs-built_in">set</span> SECRET_KEY=<span class="hljs-string">"your-secret-key"</span> | ||
flyctl secrets <span class="hljs-built_in">set</span> ACCESS_TOKEN_EXPIRE_MINUTES=30 | ||
</code></pre> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="12" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="fazendo-o-deploy">Fazendo o deploy</h2> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">fly deploy --local-only --ha=<span class="hljs-literal">false</span> | ||
|
||
<span class="hljs-comment"># ...</span> | ||
|
||
Visit your newly deployed app at https://fastzeroapp.fly.dev/ | ||
</code></pre> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="13" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="executando-as-migra%C3%A7%C3%B5es">Executando as migrações</h2> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">flyctl ssh console -a fastzeroapp -C <span class="hljs-string">"poetry run alembic upgrade head"</span> | ||
</code></pre> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="14" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="quiz">Quiz</h2> | ||
<p>Não esqueça de responder ao <a href="https://fastapidozero.dunossauro.com/quizes/aula_12/">quiz</a> dessa aula!</p> | ||
</section> | ||
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="15" data-theme="cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h" lang="en-US" style="--theme:cnyvyre85co2tlykyibcer7khleg0sqdhm9ndxz31m9h;"> | ||
<h2 id="commit">Commit</h2> | ||
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">git add . | ||
git commit -m <span class="hljs-string">"Adicionando arquivos gerados pelo Fly"</span> | ||
git push | ||
</code></pre> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script> | ||
<script>mermaid.initialize({startOnLoad:true,theme:'dark'});</script> | ||
</section> | ||
|
Binary file not shown.