jupyterhub / repo2docker

Turn repositories into Jupyter-enabled Docker images
https://repo2docker.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.63k stars 362 forks source link

Add support for using ZIP files as the repo #812

Open nuest opened 5 years ago

nuest commented 5 years ago

Proposed change

Add support for downloading ZIP files instead of a repo:

repo2docker https://example.com/an-archive.zip

This comes straight from the repo2docker roadmap, admittedly in the "later" section, but IMO this could be a good first issue for new contributors.

AFAICS this should be pretty straightforward to implement, if we can agree on the following criteria for the content provider:

Here's a little experiment for the headers:

>>> import requests
>>> requests.head('https://github.com/jupyter/repo2docker/archive/0.10.0.zip', allow_redirects=True).headers
{'Access-Control-Allow-Origin': 'https://render.githubusercontent.com', 'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'; sandbox", 'Strict-Transport-Security': 'max-age=31536000', 'Vary': 'Authorization,Accept-Encoding', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'deny', 'X-XSS-Protection': '1; mode=block', 'ETag': 'W/"0cd777a9ac8e56848f6f6b0df7b3acebc7c940035abaeea62516c93ec61d49b0"', 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename=repo2docker-0.10.0.zip', 'X-Geo-Block-List': '', 'Date': 'Thu, 14 Nov 2019 10:07:25 GMT', 'X-GitHub-Request-Id': '8B46:3ED5:7A93:101EE:5DCD275D'}
>>> 
>>> requests.head('https://nordholmen.net/test.zip', allow_redirects=True).headers
{'Content-Type': 'application/zip', 'Content-Length': '201', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=15', 'Date': 'Thu, 14 Nov 2019 10:14:47 GMT', 'Server': 'Apache', 'Last-Modified': 'Thu, 14 Nov 2019 10:14:30 GMT', 'ETag': '"c9-5974bbf467936"', 'Accept-Ranges': 'bytes'}
>>> 
>>> requests.head('https://www.dropbox.com/s/m6c2lmq6v1nn8pp/test.zip?dl=0', allow_redirects=True).headers
{'Server': 'nginx', 'Date': 'Thu, 14 Nov 2019 10:15:20 GMT', 'Content-Type': 'text/html; charset=utf-8', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'Cache-Control': 'no-cache', 'Content-Security-Policy': "base-uri 'self' ; child-src https://www.dropbox.com/static/serviceworker/ blob: ; connect-src https://* ws://127.0.0.1:*/ws ; [...] x.com/static/serviceworker/ blob:", 'Content-Security-Policy-Report-Only': "frame-ancestors 'self' 'self' ; report-uri https://www.dropbox.com/csp_log?policy_name=metaserver-experimental ; script-src 'unsafe-eval' 'unsafe-inline' https://*", 'Dropbox-Streaming': 'V=1', 'Pragma': 'no-cache', 'Referrer-Policy': 'origin-when-cross-origin',  [...], 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'Content-Encoding': 'gzip'}

Related issue: #795

Alternative options

Don't support it.

Who would use this feature?

People who want to test run (maybe privately) a repository, and users of not supported websites and repositories.

How much effort will adding it take?

Half a day.

Who can do this work?

Developer with basic Python skills, if helped with the repo2docker code base.

meeseeksmachine commented 4 years ago

This issue has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/repo2dockerspawner-alternative-version/3584/7