'How to deploy Git LFS on Heroku?
I have completed a project on Node.js which has already pushed into GitHub, this project has a video which larger than 100MB which required Git LFS. Git LFS successfully pushed into the GitHub no issue at all.
The second phase of this project is to host in Heroku, this is where I got stuck. I tried both:
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
and
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
When it's pushed using
git push heroku master --no-verify
I get the following error:
remote: -----> Git LFS app detected
remote: Env var BL_BUILDPACK_GIT_LFS_REPO is not set
remote: ! Push rejected, failed to compile Git LFS app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to intense-journey-80070.
remote:
To https://git.heroku.com/intense-journey-89070.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/intense-journey-89070.git'
How can I make this work?
Solution 1:[1]
You say
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
but you shouldn't use your app name here. I guess you want to use this buildpack? In that case, you should literally do
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
You also have an error message saying
Env var BL_BUILDPACK_GIT_LFS_REPO is not set
There is some additional configuration required for the buildpack, as outlined in its buildpack page on Heroku, which you appear not to have done:
Set the following environment variable for your app:
BL_BUILDPACK_GIT_LFS_REPOto the clone URL of the repository from which to download Git LFS assets. This should include any username, password, or personal access token which is necessary to clone noninteractively. See here for details on the syntax. It must be something like[email protected]:BureauxLocaux/my-repoBL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY: your private key encoded in base64 withbase64 -w 0. You can useheroku config:set --app preprod-bureauxlocaux "BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY=$(cat ~/.ssh/heroku_deploy_lfs | base64 -w 0)"to set it.
Private SSH keys should be protected bordering on paranoia, so make sure to use a dedicated SSH key that is only used for deployment of this repository. Give that deploy key the lowest level of permission that you can.
Solution 2:[2]
The files that are linked to Large File System (LFS) are not supported in Heroku.
So you need to move to settings on heroku to add configs vars as key “HEROKU_BUILDPACK_GIT_LFS_REPO” to value “https://@github.com//repository.git” token is a unique personal Access token. You need to register for that in your GitHub > settings> Developer Settings for Heroku to access your LFS files and also link in buildpacks to install LFS “https://github.com/raxod502/heroku-buildpack-git-lfs.git”.
Lastly, hit the deploy button in the deploy section and you are done with your project and available for people accessing over the internet.
Solution 3:[3]
Unfortunately Heroku doesn’t support git LFS at the moment.
Heroku doesn’t support git lfs. Using this method can cause pushes to fail.
https://devcenter.heroku.com/articles/git#deploy-from-a-branch-besides-main
Solution 4:[4]
Basically you can simply follow the instruction in this post. What I need to say is that when you register GitHub app, the URL you need to fill in "Webhook URL" and "Homepage URL" is both the URL you created using heroku (Example format: https://<app-name>.herokuapp.com).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Shubham Jain |
| Solution 3 | crg |
| Solution 4 |
