quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.9k stars 2.71k forks source link

deploying-to-heroku is out of date #44857

Open starksm64 opened 1 week ago

starksm64 commented 1 week ago

Description

I'm going through the https://quarkus.io/guides/deploying-to-heroku guide with a new heroku account and have run into the following 6 issues to deploy the quarkus app:

heroku create
git push heroku master
heroku open
  1. The guide says a free account is allowed, but I needed to verify a credit card to be able to attempt to push a repo. After I completed getting an app pushed, I see I'm running a basic dyno at a cost of 0.010/hour. I can go in and turn this off, but then the app is no longer accessible.

  2. The first is that master is an invalid branch name for the current getting-started repo. It should be main.

  3. The second is that there is no remote heroku repository. Running the heroku create command appears to create a tmp remote repository that would need to be added before the push:

    starksm@Scotts-Mac-Studio getting-started % heroku create
    git push heroku main  
    heroku open
    Creating app... done, ⬢ fast-eyrie-75995
    https://fast-eyrie-75995-af4ca00a28cc.herokuapp.com/ | https://git.heroku.com/fast-eyrie-75995.git
    fatal: 'heroku' does not appear to be a git repository
    fatal: Could not read from remote repository.
  4. Third, if I add the heroku remote using the previously created https://git.heroku.com/nameless-reef-15092.git repo, pushing to it fails with:

starksm@Scotts-Mac-Studio getting-started % git remote add heroku https://git.heroku.com/nameless-reef-15092.git
starksm@Scotts-Mac-Studio getting-started % git push heroku main
Enumerating objects: 3411, done.
Counting objects: 100% (3411/3411), done.
Delta compression using up to 10 threads
Compressing objects: 100% (1360/1360), done.
fatal: protocol error: bad line length character: fata
Writing objects: 100% (3411/3411), 2.59 MiB | 2.17 MiB/s, done.
Total 3411 (delta 985), reused 3394 (delta 979), pack-reused 0
fatal: the remote end hung up unexpectedly
error: failed to push some refs to 'https://git.heroku.com/nameless-reef-15092.git'

This is apparently an out of date git problem on macOS: https://help.heroku.com/GJ1XRFT5/fatal-error-pushing-to-heroku-on-macos-with-git-2-39-3-apple-git-146

Updating git using homebrew

starksm@Scotts-Mac-Studio getting-started % PATH=/opt/homebrew/bin/:$PATH
starksm@Scotts-Mac-Studio getting-started % type git                     
git is /opt/homebrew/bin//git
starksm@Scotts-Mac-Studio getting-started % git --version                
git version 2.47.1
starksm@Scotts-Mac-Studio getting-started % git push heroku main
Enumerating objects: 3411, done.
Counting objects: 100% (3411/3411), done.
Delta compression using up to 10 threads
Compressing objects: 100% (1360/1360), done.
Writing objects: 100% (3411/3411), 2.59 MiB | 609.00 KiB/s, done.
Total 3411 (delta 985), reused 3394 (delta 979), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (985/985), done.
remote: 
remote: !   Push rejected, source repository is a shallow clone. Unshallow it with `git fetch --all --unshallow` and try pushing again.
remote: 
To https://git.heroku.com/nameless-reef-15092.git
 ! [remote rejected] main -> main (shallow update not allowed)
error: failed to push some refs to 'https://git.heroku.com/nameless-reef-15092.git'

Failed because I made a shallow clone of the https://github.com/quarkusio/quarkus-quickstarts.git repo. I had to unshallow the repo using git fetch origin --unshallow. The suggested git fetch --all --unshallow did not work.

  1. pushing the repo to heroku ends up building the etire quickstart repo, not just the
    
    starksm@Scotts-Mac-Studio getting-started % git push heroku main        
    Enumerating objects: 31140, done.
    Counting objects: 100% (31140/31140), done.
    Delta compression using up to 10 threads
    Compressing objects: 100% (10030/10030), done.
    Writing objects: 100% (31140/31140), 6.49 MiB | 655.00 KiB/s, done.
    Total 31140 (delta 15326), reused 30834 (delta 15031), pack-reused 0 (from 0)
    remote: Resolving deltas: 100% (15326/15326), done.
    remote: Updated 2248 paths from ab471b96
    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote: -----> Building on the Heroku-24 stack
    remote: -----> Determining which buildpack to use for this app
    remote: -----> Java app detected
    remote: 
    remote:  !     WARNING: No OpenJDK version specified
    remote:        Your application does not explicitly specify an OpenJDK
    remote:        version. The latest long-term support (LTS) version will be
    remote:        installed. This currently is OpenJDK 21.
    remote:        
    remote:        This default version will change when a new LTS version is
    remote:        released. Your application might fail to build with the new
    remote:        version. We recommend explicitly setting the required OpenJDK
    remote:        version for your application.
    remote:        
    remote:        To set the OpenJDK version, add or edit the system.properties
    remote:        file in the root directory of your application to contain:
    remote:        
    remote:        java.runtime.version = 21
    remote:        
    remote: 
    remote: -----> Installing OpenJDK 21... done
    remote: -----> Executing Maven
    remote:        $ ./mvnw -DskipTests clean dependency:list install
    remote:        [INFO] Scanning for projects...

... remote: [INFO] ------------------------------------------------------------------------ remote: -----> Discovering process types remote: Procfile declares types -> (none) remote: Default types for buildpack -> web remote: remote: -----> Compressing... remote: ! Compiled slug size: 2.9G is too large (max is 500M). remote: ! See: http://devcenter.heroku.com/articles/slug-size remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to nameless-reef-15092. remote: To https://git.heroku.com/nameless-reef-15092.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/nameless-reef-15092.git'


5. After copying the getting-started directory to a separate directory and initializing a new git repo and readding the heroku remote repo, the app deploys, but the `heroku open` command fails because that attempts to `/` context, which has no handler. One needs to use `heroku open hello`:

```bash
starksm@Scotts-Mac-Studio getting-started % git push heroku main       
Enumerating objects: 34, done.
Counting objects: 100% (34/34), done.
Delta compression using up to 10 threads
Compressing objects: 100% (24/24), done.
Writing objects: 100% (34/34), 14.04 KiB | 4.68 MiB/s, done.
Total 34 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Updated 17 paths from 1d2525c
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-24 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Java app detected
remote: -----> Installing OpenJDK 17... done
remote: -----> Installing Maven 3.9.4... done
remote: -----> Executing Maven
remote:        $ mvn -DskipTests clean dependency:list install
remote:        [INFO] Scanning for projects...
...
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD SUCCESS
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  13.291 s
remote:        [INFO] Finished at: 2024-12-01T18:35:51Z
remote:        [INFO] ------------------------------------------------------------------------
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 79.8M
remote: -----> Launching...
remote:        Released v3
remote:        https://nameless-reef-15092-932f904bd6bc.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/nameless-reef-15092.git
 * [new branch]      main -> main
starksm@Scotts-Mac-Studio getting-started % heroku open
starksm@Scotts-Mac-Studio getting-started % heroku open /hello
maxandersen commented 1 week ago

well thats an impressive amount of papercuts - did you manage to get it all the way?

Wanna make a PR for the docs?

starksm64 commented 5 days ago

Yes, I did eventually git it to deploy, but I have not looked into whether heroku has a way to only build a submodule of a repo when doing a push. Probably the guide just needs to document cloning the quickstart repo and then making a new getting-started repo as I did unless I do find a magic setting.