jupyterhub / repo2docker-action

A GitHub action to build data science environment images with repo2docker and push them to registries.
MIT License
142 stars 28 forks source link

MyBinder still builds the image, rather than pulling it #63

Closed robertodr closed 3 years ago

robertodr commented 3 years ago

Hello, thanks for this really nice action!
Not sure whether this is a bug with the action or a bug with my usage of it. I've used successfully the action in the past, but I am currently unable to make it work properly with this repo: https://github.com/ENCCS/veloxchem-workshop The workflow including the action goes through and the image is uploaded and publicly visible: https://github.com/orgs/ENCCS/packages/container/package/veloxchem-workshop Nevertheless, MyBinder.org will always rebuild it from scratch, so there must be something wrong in my set up.

welcome[bot] commented 3 years ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

hamelsmu commented 3 years ago

I know that Binder uses repo2docker, which will scan your repository for configuration files that have the following build priority

Just taking a quick look at your repo, it seems like you have other build files in there that will signal to Binder to build, rather than use your image. I'm not sure off hand if there is a way to tell Binder that you want to build off the Dockerfile as the first priority. @choldgraf do you have any ideas for this?

hamelsmu commented 3 years ago

Oh my apologies had a slight misunderstanding.

Looks like you are trying to force MyBinder to build an image to force it cache the image. Please keep in mind that if your repo has any additional commits the cache is invalidated. Also, this is subject to MyBinder caching capacity and rules, which could change over time.

This should not be related at all to your image being publicly visible per my understanding. I tagged a friend that have more insight into this.

If you try just using mybinder.org twice in a row to start a notebook (not relying on this Action) does it build each time?

choldgraf commented 3 years ago

Yep - binder will rebuild the image based on the commit hash, so if you're changing the repo at all, a new build will trigger even if you're not changing a configuration file

robertodr commented 3 years ago

I see. I am re-running this action on every commit though. So if I wait for the Docker image to be uploaded before launching binder, shouldn't I see an almost instant startup?

choldgraf commented 3 years ago

hmmm - so the repo2docker action just builds an image and pushes it to a repository, it doesn't do anything with Binder specifically. You'd need to configure a Binder repository that pulls from wherever repo2docker-action is pushing, and leave that static so that Binder doesn't re-build it each time.

robertodr commented 3 years ago

Just to check whether I understand your last comment correctly:

  1. I can have a separate branch/repo with environment.yml and the action pushing to a package repository.
  2. The main branch has a binder/Dockerfile whose only content is the line FROM repo/package:latest.
hamelsmu commented 3 years ago

@choldgraf @robertodr no actually this Action does have the ability to cache builds directly to MyBinder.org however, if the action ends up creating commit for you then that cache will be invalidated immediately.

I see that you were using the wrong flag previously and you were supposed to use MYBINDERORG_CACHE https://github.com/ENCCS/veloxchem-workshop/commit/eeb4832cd8f8de1400a0a8fe16b113675dd630b2#diff-3f922dcd4f5c4cc190cda1ceef3c699d6267fbf980f1bb8c5dfceebaec9db038

Does it work now?

robertodr commented 3 years ago

Is it MYBINDERORG_CACHE or BINDER_CACHE together with MYBINDERORG_TAG? It looks like it's working now, but it's most likely because I've started the notebooks a couple of times in short succession :facepalm:

hamelsmu commented 3 years ago

@robertodr I would go with this example from the README, sorry meant TAG not CACHE

image

choldgraf commented 3 years ago

@hamelsmu wow this action is cooler than I remembered 😄

robertodr commented 3 years ago

Wow, yes, I feel quite silly now... I think I tried to get it to push the image to GHCR and expected it to use in on MyBinder.org automagically. Then tried to fix that and got the option names mixed up :facepalm:

As an aside, the attempt with BINDER_CACHE did work too. However, the specific repo I am working with uses LFS to store the notebooks and they would not be checked out properly.

hamelsmu commented 3 years ago

ok great! I'll close this issue then. This was also a good refresher for me as I haven't looked at this repo in some time.