<?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: siddhantvirus</title>
    <description>The latest articles on DEV Community by siddhantvirus (@siddhantvirus).</description>
    <link>https://dev.to/siddhantvirus</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%2F352921%2F5f2d15ac-c9d8-457e-bef6-1282fb810434.png</url>
      <title>DEV Community: siddhantvirus</title>
      <link>https://dev.to/siddhantvirus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siddhantvirus"/>
    <language>en</language>
    <item>
      <title>How to deploy a repository with private submodules on Heroku </title>
      <dc:creator>siddhantvirus</dc:creator>
      <pubDate>Sun, 06 Dec 2020 19:14:19 +0000</pubDate>
      <link>https://dev.to/siddhantvirus/how-to-deploy-a-repository-with-private-submodules-on-heroku-43eb</link>
      <guid>https://dev.to/siddhantvirus/how-to-deploy-a-repository-with-private-submodules-on-heroku-43eb</guid>
      <description>&lt;p&gt;A few days ago, I was trying to deploy a NodeJS application on Heroku. When I was trying to push the same to Heroku using the Heroku CLI, I got an error stating that the deployment failed, since the CLI could not access the private submodule.&lt;br&gt;
The &lt;a href="https://devcenter.heroku.com/articles/git-submodules#protected-git-submodules"&gt;Heroku documentation&lt;/a&gt; provides a workaround for this to allow it to resolve Private Submodules in non-local environments —&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For instance, to add the FooBar submodule using an HTTP basic authentication URL scheme (note the presence of the username:password tokens):&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;git submodule add https://username:password@github.com/myusername/FooBar&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The problem with the method is that git submodule references are stored in plaintext in the &lt;code&gt;.git/submodules&lt;/code&gt; directory, and thus, it can be a security issue.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Heroku allows us to deploy an application using a container as well.&lt;br&gt;
Thus, I created a simple Dockerfile to build my project and then push it to Heroku's Container Registry. &lt;br&gt;
This example uses a NodeJS project to show the same.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This &lt;code&gt;Dockerfile&lt;/code&gt; needs to be added to the root folder of your NodeJS folder.&lt;/p&gt;

&lt;p&gt;You also need to add a &lt;code&gt;.dockerignore&lt;/code&gt; file as follows: &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Heroku will always ignore the PORT you have set for your project, and thus your NodeJS app must use the value &lt;br&gt;
&lt;code&gt;const PORT = process.env.PORT || 5000&lt;/code&gt; to ensure that the project runs both locally and on the Heroku deployment.&lt;/p&gt;

&lt;p&gt;After this follow the given steps using &lt;a href="https://devcenter.heroku.com/articles/heroku-cli#download-and-install"&gt;Heroku CLI&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku login
$ heroku container:login 
$ heroku create &amp;lt;optional app name&amp;gt;
$ heroku container:push web
$ heroku container:release web
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we first login to our Heroku Account and then the &lt;a href="https://devcenter.heroku.com/articles/container-registry-and-runtime"&gt;Heroku Container Registry&lt;/a&gt;, followed by creating a new Heroku app and then building the Docker image using &lt;code&gt;push&lt;/code&gt; and then using the &lt;code&gt;release&lt;/code&gt; command to "release" the image to your app.&lt;/p&gt;

&lt;p&gt;You can then use &lt;code&gt;heroku open&lt;/code&gt; to access your application!&lt;/p&gt;

&lt;p&gt;Congratulations 🎉, you have now deployed your project on Heroku using Containers and even avoided having to copy the submodules to a new Repository or compromising your security by saving the password in plaintext.&lt;/p&gt;

&lt;p&gt;You can repeat the given steps every time you have a new build!&lt;/p&gt;

&lt;p&gt;I hope this helps someone 😄&lt;/p&gt;

&lt;h3&gt;
  
  
  Credits :
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;span&gt;Cover Photo by &lt;a href="https://unsplash.com/@hckmstrrahul?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Rahul Chakraborty&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/docker?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devcenter.heroku.com/categories/reference"&gt;Heroku Dev Center&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>heroku</category>
      <category>node</category>
      <category>docker</category>
      <category>git</category>
    </item>
  </channel>
</rss>
