<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NicolasArayaB</title>
    <description>The latest articles on DEV Community by NicolasArayaB (@nicolasarayab).</description>
    <link>https://dev.to/nicolasarayab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F628942%2Fbce89de4-42ca-4c3c-ac7f-27f7472d8954.jpeg</url>
      <title>DEV Community: NicolasArayaB</title>
      <link>https://dev.to/nicolasarayab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nicolasarayab"/>
    <language>en</language>
    <item>
      <title>Deploy en Heroku</title>
      <dc:creator>NicolasArayaB</dc:creator>
      <pubDate>Thu, 13 May 2021 02:27:55 +0000</pubDate>
      <link>https://dev.to/4geeksacademy/deploy-en-heroku-5gnc</link>
      <guid>https://dev.to/4geeksacademy/deploy-en-heroku-5gnc</guid>
      <description>&lt;p&gt;Utilizando el boilerplate &lt;a href="https://github.com/4GeeksAcademy/react-flask-hello/tree/main/docs"&gt;react-flask-hello&lt;/a&gt;, realizar el deploy de tu applicación es bastante simple.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lo primero es crear una cuenta en &lt;a href="https://heroku.com"&gt;Heroku&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Una vez tengas la cuenta, instalas heroku:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ npm i heroku -g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Crea la app en heroku:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ heroku create &amp;lt;your_application_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Agregas Python y Node.js para poder usar npm en producción:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ heroku buildpacks:add --index 1 heroku/python
  $ heroku buildpacks:add --index 2 heroku/nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Agregas una base de datos. Para esto, puedes revisar &lt;a href="https://elements.heroku.com/addons"&gt;aca&lt;/a&gt; cual es la opción que se adecua mejor a tus necesidades. En el caso de MySQL, puedes usar JawsDB MySQL ya que da una opción gratis de la siguiente manera:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   heroku addons:create jawsdb:kitefin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Si utilizas PostgreSQL, puedes utilizar Heroku Postrgres:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ heroku addons:create heroku-postgresql:hobby-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Si estas utilizando PostgreSQL, debes realizar un paso extra. Debido a que se genera automaticamente la 'DATABASE_URL' con el paso anterior, debemos agregar en /src/app.py, .replace("://", "ql://", 1) de esta manera:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # database configuration
  if os.getenv("DATABASE_URL") is not None:
    app.config['SQLALCHEMY_DATABASE_URI'] = 
  os.environ.get('DATABASE_URL').replace("://", "ql://", 1)
  else:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Luego agregamos el resto de las variables del archivo .env de la siguiente forma:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ heroku config:set FLASK_APP_KEY="any key works"
  $ heroku config:set FLASK_APP=src/app.py
                   # Importante: En archivo .env está en 
                     development, heroku hay que setearlo para 
                     producción     ↓
  $ heroku config:set FLASK_ENV=production 
  $ heroku config:set BASENAME=/
                   # Importante: Esta variable tiene que     
                     quedar vacia   ↓
  $ heroku config:set BACKEND_URL=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Si tienes cambios pendientes, solo guarda y ya estas listo para hacer el deploy:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  $ git add .
  $ git commit -m 'deploying to heroku'
  $ git push heroku main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>heroku</category>
    </item>
  </channel>
</rss>
