Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git-lfs to image #654

Open
jameshearttech opened this issue Dec 22, 2022 · 35 comments
Open

Add git-lfs to image #654

jameshearttech opened this issue Dec 22, 2022 · 35 comments

Comments

@jameshearttech
Copy link

I'm requesting git-lfs be added to the image. This issue came up back in 2019 #174. The issue was closed without adding git-lfs to the image. I tested v3.6.2 by adding git-lfs to the image and I'm syncing LFS files from BitBucket without any additional configuration.

This is my dockerfile.

FROM k8s.gcr.io/git-sync/git-sync:v3.6.2
USER root
RUN apt-get update
RUN apt-get -y install git-lfs
USER 65533:65533

This is my container spec within my deployment in k8s.

spec:
  template:
    spec:
      containers:
        - name: git-sync-lfs
          image: example-docker-hub/git-sync-lfs:v3.6.2
          args:
            - -ssh
            - -repo=git@bitbucket.org:example-private-repo/lfs.git
            - -root=/data
            - -dest=lfs
            - -branch=master
            - -depth=1
            - -wait=60
          resources:
            limits:
              cpu: 200m
              memory: 200Mi
            requests:
              cpu: 100m
              memory: 100Mi
          volumeMounts:
            - name: lfs-data
              mountPath: /data
            - name: git-secret
              mountPath: /etc/git-secret
          securityContext:
            runAsUser: 65533
@thockin
Copy link
Member

thockin commented Dec 22, 2022

I would want an e2e test for this - how do I force this to be used so I know it works?

@jameshearttech
Copy link
Author

jameshearttech commented Dec 23, 2022

Do existing tests not cover this? Can I not just add git-lfs package in a Dockerfile using apt-get then run tests on new image?

My background is sysadmin. I'm new to devops. I know some bash, docker, and k8s. You want me to write a test to prove that it works? Not sure how to do that.

I forked the repo. I'm looking at Dockerfile.in and test_e2e.sh. I'm not sure where to add git-lfs package in Dockerfile.in. Do I pass it an image:tag as an argument to run tests?

@thockin
Copy link
Member

thockin commented Dec 23, 2022 via email

@jameshearttech
Copy link
Author

jameshearttech commented Dec 23, 2022

Does this help? GitHub - Configuring Git LFS

GitHub provides some storage and bandwidth for LFS for free. GitHub - About Storage and Bandwidth

We can do a call and work through it together if you'd like. I set it up on BitBucket, but it's probably similar on GitHub. The BitBucket repo I have setup is private, but I could setup a public repo if that helps.

Afaik the only thing that will be different after adding the git-lfs package will be that if a repo contains lfs files they will be synced rather than the text files that point to them. This makes me think existing tests should be fine, but I'm far from and expert.

@thockin
Copy link
Member

thockin commented Dec 23, 2022 via email

@jameshearttech
Copy link
Author

If you setup a public GitHub repo with LFS I don't think you need authentication.

@jameshearttech
Copy link
Author

Do the existing tests use a git repo to test? Maybe just add an LFS file to that repo?

@thockin
Copy link
Member

thockin commented Dec 23, 2022 via email

@jameshearttech
Copy link
Author

jameshearttech commented Dec 24, 2022

In my fork I have setup lfs-test-server using the sshd folder as an example.

_test_tools
├── lfs-test-server
│   ├── Dockerfile
│   ├── README.md
│   └── run.sh
├── ncsvr
│   ├── Dockerfile
│   ├── README.md
│   └── ncsvr.sh
└── sshd
    ├── Dockerfile
    ├── README.md
    ├── sshd.sh
    └── sshd_config

I am using env vars LFS_USERNAME and LFS_PASSWORD to configure lfs-test-server management username and password. Looking at sshd example I'm assuming we don't want these committed to the repository. Not sure how I'm going to do that. If you don't set these the management interface is not accessible. Also, it looks like you have to login and create a user to use lfs-test-server. Not how I'm going to work around that either. Any ideas?

@thockin
Copy link
Member

thockin commented Dec 26, 2022

Ugh, what a cumbersome piece of software to automate. How about something like this Dockerfile:

FROM alpine AS base                                                                                                                                   

RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN apk add --no-cache --initdb -p /out \
    alpine-baselayout \
    apk-tools \
    curl \
    && true

###############

FROM scratch

ENTRYPOINT []
WORKDIR /

COPY --from=base /out/ /

COPY lfs-test-server /

RUN LFS_ADMINUSER=admin \
    LFS_ADMINPASS=admin \
    timeout 2 \
    /lfs-test-server & \
    sleep 0.5 \
    && curl -s localhost:8080/mgmt/add -u admin:admin -X POST -F name=e2e -F password=e2e

ENTRYPOINT ["/lfs-test-server"]

I did a quick test and that SEEMS to work, as long as lfs-test-server is built with CGO_ENABLED=0 (static binary).

Now you can run the image in docker, get the IP (see ssh examples) and us username "e2e" password "e2e".

@jameshearttech
Copy link
Author

jameshearttech commented Dec 27, 2022

I take it from your comment committing the credentials in git is not an issue? I saw in sshd that the certs were in a volume that was not committed.

@thockin
Copy link
Member

thockin commented Dec 27, 2022 via email

@jameshearttech
Copy link
Author

That makes sense. I just wanted to check before moving forward. Btw adding the user with curl that way is just what I was looking for. I'll keep working on this. Thanks.

@jameshearttech
Copy link
Author

Haven't circled back to this yet, but I will. Please don't let the issue go stale and close. Thanks!

@thockin
Copy link
Member

thockin commented Feb 26, 2023

Hi. I am hoping to have a v4.0.0 release candidate some time in the next month or so - would love to have this in. No pressure, we can always add it later.

@jameshearttech
Copy link
Author

I'll put some time toward this over the next few weeks.

@jameshearttech
Copy link
Author

I'm working on test_e2e.sh. I added a section to init lfs-test-server.

# Init Git LFS Test Server

# Clone lfs-test-server to _test_tools
git clone https://github.com/git-lfs/lfs-test-server ./_test_tools/lfs-test-server

# Overwrite lfs-test-server Dockerfile
tee ./_test_tools/lfs-test-server/Dockerfile <<EOF
FROM golang:1.18
WORKDIR /go/src/github.com/git-lfs/lfs-test-server
COPY . .
RUN go build
EXPOSE 8080
ENV LFS_ADMINUSER=admin
ENV LFS_ADMINPASS=admin
RUN /go/src/github.com/git-lfs/lfs-test-server/lfs-test-server & \
    sleep 0.5 \
    && curl -s localhost:8080/mgmt/add -u admin:admin -X POST -F name=e2e -F password=e2e
ENTRYPOINT ["/go/src/github.com/git-lfs/lfs-test-server/lfs-test-server"]
EOF

# Build the lfs-test-server image
docker build ./_test_tools/lfs-test-server -t example.com/lfs-test-server:latest

# Run the lfs-test-server container
docker run --rm -d -p 8080:8080/tcp example.com/lfs-test-server:latest

The shell snippet works. Idk if that's what you had in mind. I'm also looking at modifying the init_repo function.

function init_repo() {
    rm -rf "$REPO"
    mkdir -p "$REPO"
    git -C "$REPO" init -q -b "$MAIN_BRANCH"
    touch "$REPO"/file
    git -C "$REPO" add file
    git -C "$REPO" commit -aqm "init file"

    cd "$REPO"
    git lfs install
    git lfs track "*.jpg"
    cd ..
    echo "[lfs]" > "$REPO"/.lfsconfig
    echo "    url = \"http://localhost:8080/\"" >> "$REPO"/.lfsconfig
    git -C "$REPO" add .lfsconfig .gitattributes
    git -C "$REPO" commit -aqm "lfs config"

    touch "$REPO"/lfs.jpg
    git -C "$REPO" add lfs.jpg
    git -C "$REPO" commit -aqm "add lfs.jpg"

    rm -rf "$REPO2"
    cp -r "$REPO" "$REPO2"
}

To confirm the lfs tracked file is sent to lfs-test-server we need to git push, but for that we need a remote.

@thockin
Copy link
Member

thockin commented Mar 12, 2023 via email

@jameshearttech
Copy link
Author

I've been looking at the repo trying to understand how to do this, but I don't quite follow how everything works. Would it be better if I put the script at /test-lfs.sh?

@thockin
Copy link
Member

thockin commented Mar 14, 2023 via email

@jameshearttech
Copy link
Author

Tbh, there's not much to see at this point. After working on it a bit last weekend I have a better idea of which direction to go. I'm going to work on it again this weekend a bit more, so we'll see how it goes.

@jameshearttech
Copy link
Author

jameshearttech commented Mar 20, 2023

I worked with it a bit more and made a little progress. I got a lfs-test-server container along with a git-server-docker container setup and was able to push a commit to git-server-docker containing a jpg that was pushed to lfs-test-server.

I'll throw a bit more time at it next weekend. I feel it's starting to come together, but there is still a ways to go. Ultimately, I want to automate the setup of an environment where we have a repo in git-server-docker and a large file in lfs-test-server such that when we clone the repo with git-sync it pulls the large file with the repo.

Are we on the same page with that goal?

@thockin
Copy link
Member

thockin commented Mar 21, 2023 via email

@thockin
Copy link
Member

thockin commented Apr 7, 2023

Circling around to open topics - any progress here?

@jameshearttech
Copy link
Author

I have not had time the past couple of weeks. Tomorrow I'll have some time to pick this up again. Idk how far I'll get, but I'll keep at it until it's done.

@jameshearttech
Copy link
Author

jameshearttech commented Apr 21, 2023

I talked with my manager and received approval to start dedicating some of my work time to OSS. This is at the top of my list!

@thockin
Copy link
Member

thockin commented Apr 21, 2023

That's awesome! Congrats.

@jameshearttech
Copy link
Author

jameshearttech commented Apr 24, 2023

I updated my fork. It's not working yet and it's rough, but if you want to take a look.

@jameshearttech
Copy link
Author

@thockin I have not forgotten about this, but I'm on a modified schedule until the end of June with no time for oss. I'll circle back to this in July. Sorry I'm slow and inexperienced.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 22, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 21, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

@k8s-ci-robot k8s-ci-robot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jameshearttech
Copy link
Author

Bad bot.

@thockin
Copy link
Member

thockin commented Mar 25, 2024

I can re-open if you still want to tackle this, but the bot just sweeps up debris which is often left behind by well-intentioned people who just can't find/make the time to finish (IOW, me, frequently).

@thockin thockin reopened this Mar 25, 2024
@thockin thockin removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants