-
Notifications
You must be signed in to change notification settings - Fork 177
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
Initial docker setup in core ODC repo #382
Conversation
This is required to stop the warnings being printed to stdout
The Dockerfile uses the standard install process from the readme, and uses the local files in the repo to install from.
This is a first step in setting up a docker-compose file to use in interactive development.
+1 |
docker-compose.yml
Outdated
datacube: | ||
build: . | ||
volumes: | ||
- ./:/code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are we using a volume for code or are we copying code during build?
Seem to be doing both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Kirill, the docker-compose file uses the Dockerfile as a base, so that dependencies are already installed, and then mounts in the volume so that it has your local changes. This means you can change your code locally, and run it in Docker with the changes without rebuilding the image and creating a new container.
Note that it's using the path to the cli_app.py
so that it is not using the installed version of the Open Data Cube, it's using the one from your local directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but won't it trigger rebuild anyway, since you changed folder content and that get's copied into the docker, so from COPY down things will need to be redone anyway?
Also we use python "entry points" (https://amir.rachum.com/blog/2017/07/28/python-entry-points/), how this will interact with the proposed setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Docker Compose, the first build is mandatory, but later builds are manually triggered (with docker-compose build
). So no, it won't trigger a new build.
I'm aware of the entry points in the setup.py
file, and that's where I copied the main one from. I think a Docker Compose file can only have one in it, so unless we set up a whole new way of doing it, the other commands will need to be referenced by their full path. That'll probably need to be documented.
Just FYI, if you use this docker-compose file, the entrypoint commands (like datacube
and pixeldrill
) will still work, but if you use them, they will point to the installed version, and not the version mounted by the volume. That's a bit of a gotcha. To run code that you have changed, you need to use the path, like /code/datacube/scripts/cli_app.py
.
Dockerfile
Outdated
# Get the code, and put it in /opt | ||
ENV APPDIR=/code | ||
RUN mkdir -p $APPDIR | ||
COPY . $APPDIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure about "getting code from working copy strategy".
I'd rather fetch directly from github with a hash/tag/branch supplied as build argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept here is that the Dockefile is in with the code, so that it can be automatically built using Docker Cloud. We can configure tagged builds that are in sync with this repo automatically that way.
At the moment, I'm thinking we have a latest
tag for the docker image coming out of the develop branch (that should always build and work, right?) and then tagged builds from releases.
It was suggested that we do the install from PIP, since that's the 'point of truth'. But if we have the code local to the build, it's not necessary to go to GitHub and fetch it again.
In thinking about this, the docker-compose file should really bring up Postgres too, as well as passing in DB username and password parameters. Are there any other requirements for a fully functioning development environment? Maybe a /data directory mounted in as a volume? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good Alex. I think the main thing missing now is documentation. Including a Dockerfile
is a good start, but new users are going to need guidance in how to use it, and what is included..
Adopting Docker as a Development and Test environment sounds reasonable to me, initially as an alternative to the current conda methods.
Eventually we could consider making Docker the primary supported development environment, maybe.
setup.py
Outdated
@@ -84,7 +84,7 @@ | |||
'jsonschema', | |||
'netcdf4', | |||
'numpy', | |||
'psycopg2', | |||
'psycopg2-binary', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should still depend on psycopg2
. The binary package is available as an installation option, but, not a package that should be depended on.
By recent discussions at psycopg2 issue 674, it also doesn't sound to be completely resolved.
It would be totally fine to pip install psycopg2-binary
in the Dockerfile, but leave the dependency alone.
As discussed today, I've updated this PR with the following changes:
|
Another change. It now has an entrypoint script that sets up the config file. This does need documenting... @omad (or others), where should I document it? |
Just add something to the bottom of the README. I don't think inflicting the rest of the docs on you is necessary, yet. :) Also, I'm not quite sure where in there to put it. |
I've added something to the readme. Took me a little while to realise restructured text is different to markdown! |
Ok, folks, how are we going with this? It would be great if we can get it merged in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great start. Thanks Alex.
I'm sure there'll be issues and improvements required. But it's all new, so there's no chance of negatively impacting anything and is safe to merge.
Might be worth cleaning the pip cache with |
Aw, @roarmstrong, you were too late! That's a great idea, though. There are probably a few other things to consider, such as explicitly adding only the files that we need for each step, and removing them after. Also, I will set the auto-build up on the |
Reason for this pull request
This PR includes a suggested way to include a Dockerfile and docker-compose configuration for development.
Proposed changes
Add a docker-compose file, which enables a dev environment with standard dependencies from the above Docker imageChanges a dependency for the recommended one (psycopg2 for psycopg2-binary)Edit: I think this is ready to go now.
added/ passeddocs/about/whats_new.rst
for all changes