skyfielders / python-skyfield

Elegant astronomy for Python
MIT License
1.41k stars 211 forks source link

Docker? #274

Closed ghost closed 4 years ago

ghost commented 5 years ago

Feature request: Docker seems to be getting quite popular these days, so maybe create a docker container of skyfield and upload it to https://hub.docker.com/

I realize some people have already created Docker files (not on hub.docker.com), but it might be nice to have an "official" Docker image.

brandon-rhodes commented 5 years ago

Usually I start with one of the Python "slim" containers and pip install skyfield as the next step in the Dockerfile. My guess is that asking folks to use pip will be far more sustainable for the Skyfield project, long-term, than having another upload format that we have update and maintain with each Skyfield release?

ghost commented 5 years ago

The main advantage of Docker, in my opinion, is that people can get skyfield up and running without having to worry about dependencies, version conflict, etc. They don't even need to have Python installed, and Docker works on Mac and Windows not just Linux.

It makes a great "ad" for skyfield in the sense that people can grab the docker file no hassle, test it with sample scripts (or even their own code) and decide if it's worth installing on their main machine (or just keep the docker image).

People who think skyfield "might be useful" would normally worry that installation will be ugly and avoid installing it just to test it.

You can auto-build Docker containers from git releases. I'm not sure exactly how, but it shouldn't disrupt/increase the workflow too much.

brandon-rhodes commented 5 years ago

If you can find a suggested workflow, I'd be interested. But in the other direction: what if we provided a sample Dockerfile? Are those as easy for people to use as images?

ghost commented 5 years ago

https://docs.docker.com/docker-hub/builds/link-source/ is docker's reference on auto-creating Docker images from github

I'm new to Docker myself, but I think the Dockerfile just tells Docker how to build an image when you already have the necessary software installed. In other words, a Dockerfile would help you, the software producer, create a Docker image. The end user wouldn't even see the Dockerfile.

brandon-rhodes commented 5 years ago

... when you already have the necessary software installed ...

Happily, a Dockerfile does not require any software to already be installed (apart from Docker). It builds a new image from the ground up. A pip install skyfield in the Dockerfile would result in a Docker image with Skyfield ready to use.

I'll look over those docs once I'm home from PyCon Australia, but I'm not sure that the 3-line Docker file anyone could write to try out Skyfield from Python is difficult enough that it's worth storing entire copies of Ubuntu just to have a single Python package installed on them. But feel free to update this issue if you come across a compelling use case!

ghost commented 5 years ago

Brandon, if I understand correctly, you're wanting to distribute a Dockerfile so that end users could:

Is that correct?

If so, would the Dockerfile create the same image for everyone, even when dependencies or python or skyfield is updated? In other words, would an image created tomorrow necessarily be identical to an image created today?

If not, I still think a Docker image is a good idea because it guarantees users a known working environment. They don't have to worry about updates or bugs in new versions of anything-- their environment will continue to work, even though it may not have the latest features.

brandon-rhodes commented 4 years ago

If so, would the Dockerfile create the same image for everyone, even when dependencies or python or skyfield is updated? In other words, would an image created tomorrow necessarily be identical to an image created today?

Yes, if the pip install command in the Dockerfile was careful to pin the versions of Skyfield and NumPy and each other dependency. The only possible deviation would be something like security patches to the underlying Ubuntu image, since Docker files often start with something like apt update && apt upgrade -y -y.

Given many other issues that need attention, I am going to close this for now since we don't have any actual users who have arrived yet asking for an official way to install a reproducible environment. When they do, I suspect we'll not want to look at Docker but maybe something like Binder:

https://mybinder.org/

Since in that case they would not even need to install the dependencies locally, though they could if they wanted to.