DEV Community

Markus Cadonau
Markus Cadonau

Posted on • Originally published at cadonau.net

DeployBot Configuration with Git LFS

I recently started using Git LFS for image and video files in an existing repository. Migrating the repository to Git LFS would be another Odyssean story.

However, since I’m using DeployBot to deploy the repository to a web server, I also had to make sure it would handle the files properly, i.e. the actual image files, not the text pointers would be transferred to the host.

An answer to DeployBot’s “common questions about build tools” says:

Unfortunately, we do not yet support LFS by default. But it is possible to use Git LFS right now by using build tools. Inside the container, you are free to install the LFS plugin and set things up yourself. You could also use a command to install the LFS distribution.

It took me a while to figure out how to do it but I think it now works for my scenario. It’s probably not ideal; I will try to update this post, if I change my configuration. Let me go through what I’ve tried:

First Attempt

I started configuring my own container based on the existing Ubuntu 18.04 one with the

Build commands

apt install git-lfs
git lfs install --system
Enter fullscreen mode Exit fullscreen mode

to install Git LFS and set its Git hooks up.

That alone was not sufficient. Git LFS was set up — so I kept the setting — but text pointers were being deployed.

Second Attempt

In the deployment server settings, by adding the following commands to the Build Tools section

Compile, compress, or minimize your code

cd /source/
git lfs pull
Enter fullscreen mode Exit fullscreen mode

I tried to make Git LFS replace the text pointers with the media files. Yet, text pointers were still being deployed.

Third Attempt

Realizing that the files weren’t being pulled from my original (Github) repository, I modified

Compile, compress, or minimize your code

cd /source/
git remote set-url origin %REPO_URL%
git lfs pull
Enter fullscreen mode Exit fullscreen mode

so that the ”origin” remote was set to my repository, not to some intermediate one by DeployBot.

While this worked, DeployBot viewed all LFS files as different and always deployed all of them again.

Fourth Attempt

Once again, I modified

Compile, compress, or minimize your code

cd /source/
git checkout -b deploy %PREVIOUS_COMMIT%
git remote set-url origin %REPO_URL%
git pull origin %BRANCH%
Enter fullscreen mode Exit fullscreen mode

to only pull the files from my repository that were modified since the last deployed commit.

This worked until I had to roll back for the first time since making these configuration modifications.

Fifth Attempt (and final, for now)

By first checking whether a rollback was happening, I finally managed to configure DeployBot with Git LFS to my satisfaction. For completeness sake, I’m including all parts of my current configuration, again:

Build commands

apt install git-lfs
git lfs install --system
Enter fullscreen mode Exit fullscreen mode

Compile, compress, or minimize your code

cd /source/
if [ %ROLLBACK?% != 1 ]; then
git checkout -b deploy %PREVIOUS_COMMIT%
git remote set-url origin %REPO_URL%
git pull origin %BRANCH%
fi

Enter fullscreen mode Exit fullscreen mode




Issues/Updates (October 2021)

  • For reasons I haven’t yet figured out, renamed/moved LFS files were — once again — not properly pulled and deployed.

Discussion (0)