How do I deploy an Angular app to Heroku using Gitlab?

Asked

Viewed 276 times

2

Angular Use 5 (5.2.10) and Angular CLI (1.7.4) and I would like to deploy to Heroku, but my files are in the Gitlab repository. Some more information: Node (8.11.1) and npm (5.6.0).

1 answer

1

The Heroku supports deploy with Git natively, just add a new remote to the repository for Heroku and push for this remote.

I tried to make something similar with my Azure Web App - a SPA in Angular - and the obstacle I found is not being able to do push direct from the Angular project repository because Angular is transpiled into Javascript in the act of build. So you have two options:

  1. Create a new repository in the output of transpilation (normally ../dir_do_projeto/dist) with Heroku as remote - which is easy to trouble because of having a repository inside another repository;
  2. Create a new local repository in your development environment with Heroku as remote where it manually copies the dist whenever you want to do deploy.

I would personally opt for the second option since I encountered problems with the previous one. Either way I have plenty of colleagues who prefer the 1st option for simplicity and do not need their manual interaction.


Useful resources:

  • For now thanks, I will give a "studied", are many technical terms in a few lines. I do not know what is a SPA, in the folder of output of transpilation and so on.

  • @Rafaelsouzacalearo I just edited the answer with some resources that explain these questions. Give a look!

  • Okay, I’ll look and I’m very grateful for the understanding and help! Just one more detail, is my project in the Gitlab repository, don’t I need to do any local and/or remote configuration (Gitlab/Heroku)? Because I have the same application on Github and there I had to make some modifications (tbm on Heroku) so yes I was able to publish on Heroku. That is, only with a native Git Deploy will I be able to do the explanations you gave me? Excuse my ignorance.

  • I’ve never used Heroku so I can’t understand what you’re talking about... Give me an example?

  • My question was if I had to set something up in Heroku or Gitlab to do it the way you did, because I used Github once and had to make settings in my Heroku and application (I created new files, installed dependencies, etc.). But I’m still doing (reading) what you put as an answer!

  • In principle no, what you probably need to do is set up Heroku to support deploys via Git, which is explained in one of the resources in the above answer. It’s just a matter of setting up the remote in your local repository and whenever you want to update your project in Heroku, push to Gitlab, push to Heroku.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.