Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download a specific git-lfs file into a Docker container

I have a git repo with several large files. Git-LFS is enabled. I want to bring in one of the files into a Docker container. I have installed git-lfs in the container. So far I have:

RUN git clone --no-checkout --depth 1 https://github.com/my-org/my-data-repo.git
RUN cd my-data-repo
RUN git lfs pull -I data/my-large-file.csv

The file actually get's downloaded but the Docker build process fails because I get the following error:

Error updating the git index: (1/1), 90 MB | 4.8 MB/s                                                                                                                                                                                       
error: data/my-large-file.csv: cannot add to the index - missing --add option?
fatal: Unable to process path data/my-large-file.csv


Errors logged to .git/lfs/logs/20200709T142011.864584.log
Use `git lfs logs last` to view the log.

How can do this without an exception being thrown which kills the Docker build process?

like image 649
MoreScratch Avatar asked Oct 26 '22 20:10

MoreScratch


People also ask

Where are git LFS files stored?

Git LFS stores the binary file content on a custom server or via GitHub, GitLab, or BitBucket's built-in LFS storage. To find the binary content's location, look in your repository's . git/lfs/objects folder.


1 Answers

One of your issues is :

RUN cd my-data-repo
RUN git lfs pull -I data/my-large-file.csv

doesn't work as you expect :

  • a first process is started, in which cd my-data-reop sets the current directory to my-data-repo,
  • this process is then ended (along with its working directory)
  • a second process is then started, which runs git lfs pull ... from the intital directory

You can either group your commands :

RUN cd my-data-repo && git lfs pull -I data/my-large-file.csv

or use the WORKDIR command (as suggested here) :

WORKDIR my-data-repo
RUN git lfs pull -I data/my-large-file.csv
like image 179
LeGEC Avatar answered Nov 14 '22 07:11

LeGEC