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

POCS in the Dock(er) #778

Closed
wants to merge 125 commits into from
Closed

POCS in the Dock(er) #778

wants to merge 125 commits into from

Conversation

wtgee
Copy link
Member

@wtgee wtgee commented Feb 4, 2019

This presents a number of changes for building and running POCS and friends
in a docker environment. As of this PR, starting the environment (via docker-compose)
will launch four separate services (container images):

  • messaging-hub
  • weather
  • paws
  • pocs

As of now, it will also map the following directories to the host:

  • $PANDIR/json_store
  • $PANDIR/logs
  • $PANDIR/images
  • $PANDIR/POCS

It also appropriately sets up the internal network that allows the services to communicate
with each other over zeromq and exposes port 8080 on the host machine for reaching
PAWS.

The environment can be started with a helper script:

$POCS/scripts/run_pocs_docker.sh [help|jupyterlab]

As of now there is one additonal option that can be passed (jupyterlab) which
will start a jupyterlab environment within the running pocs service, exposing port
8888 on the host for access.

The POCS repo is installed in development mode (i.e. pip install -e .) so that changes
to the $POCS dir on the host will be reflected in the running service.

To do still:

  • Environment sensors a la the weather container.
  • Convenience script to make it easier for non-technical users to install docker, authenticate,
    pull images, etc.
  • Lots more I'm sure.

Note: this runs all of the docker images in privileged mode, meaning they have access to the host.

Also:

  • Dockerfile to create a pocs-base image that contains the POCS repository
    installed on an ubuntu 18.04 base image. This includes an install of all the
    dependencies, including astrometry.net. Some of the apt-packages have been
    cleaned up or changed as part of this PR.
  • docker-compose.yaml files for easily starting all of the containers and helpers.
  • Bash script for starting environments.
  • Helper scripts for starting services. The POCS script ($POCS/scripts/docker/run_pocs.sh) still needs some work.
  • Small README updates (more likely to come).
  • $PANUSER is root as everything is run inside the images.
  • The default python3 in ubuntu is used rather than dealing with anaconda. This helps keeps the image size smaller.

Closes #734

Note: The images are currently built and stored in our Google Container Registry rather than on Dockerhub. The base is gcr.io/panoptes-survey.

There is a coming PR for https://github.com/panoptes/PAWS that this PR relies on.

wtgee added 7 commits January 31, 2019 12:20
* Use apt packages from defined list
* Don't use conda (our whole container is our app so using system python is fine)
* Astrometry comes from apt; index files will be a docker volume
Base file for running unit could be used with just

`docker-compose up`

Whereas development can use

`docker-compose -f docker-compose.yml -f docker-compose.dev.yaml`

which will merely bind the host `$POCS` dir to the container.
This makes it so we can connect across a different network, not just localhost.
The main usage will probably be within a private network while running docker
so we turn a blind eye to any security.
This presents a number of changes for building and running POCS and friends
in a docker environment. As of this PR, starting the environment (via docker-compose)
will launch four separate services (container images):

* messaging-hub
* weather
* paws
* pocs

As of now, it will also map the following directories to the host:

* $PANDIR/json_store
* $PANDIR/logs
* $PANDIR/images
* $PANDIR/POCS

It also appropriately sets up the internal network that allows the services to communicate
with each other over zeromq and exposes port 8080 on the host machine for reaching
PAWS.

The environment can be started with a helper script:

```bash
$POCS/scripts/run_pocs_docker.sh [help|jupyterlab]
```

As of now there is one additonal option that can be passed (`jupyterlab`) which
will start a jupyterlab environment within the running pocs service, exposing port
8888 on the host for access.

The POCS repo is installed in development mode (i.e. `pip install -e .`) so that changes
to the `$POCS` dir on the host will be reflected in the running service.

To do still:
* Environment sensors a la the weather container.
* Convenience script to make it easier for non-technical users to install docker, authenticate,
pull images, etc.
* Lots more I'm sure.

Note: this runs all of the docker images in `privileged` mode, meaning they have access to the host.

Also:
* Dockerfile to create a `pocs-base` image that contains the POCS repository
installed on an ubuntu 18.04 base image. This includes an install of all the
dependencies, including astrometry.net. Some of the apt-packages have been
cleaned up or changed as part of this PR.
* docker-compose.yaml files for easily starting all of the containers and helpers.
* Bash script for starting environments.
* Helper scripts for starting services. The POCS script (`$POCS/scripts/docker/run_pocs.sh`) still needs some work.
* Small README updates (more likely to come).
@wtgee wtgee requested a review from jamessynge February 4, 2019 20:41
@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #778 into develop will decrease coverage by 1.6%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #778      +/-   ##
===========================================
- Coverage    81.49%   79.88%   -1.61%     
===========================================
  Files           69       68       -1     
  Lines         5581     5519      -62     
  Branches       769      759      -10     
===========================================
- Hits          4548     4409     -139     
- Misses         836      915      +79     
+ Partials       197      195       -2
Impacted Files Coverage Δ
peas/sensors.py 35.71% <0%> (-0.58%) ⬇️
pocs/utils/images/__init__.py 61.83% <0%> (ø) ⬆️
pocs/utils/messaging.py 67.46% <63.63%> (-10.32%) ⬇️
pocs/core.py 84.74% <75%> (+0.04%) ⬆️
pocs/utils/database.py 72.34% <0%> (-15.61%) ⬇️
pocs/utils/google/storage.py 22.85% <0%> (-12.15%) ⬇️
pocs/observatory.py 90.03% <0%> (-1.28%) ⬇️
pocs/scheduler/__init__.py 100% <0%> (ø) ⬆️
pocs/utils/location.py

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4476d3b...85118ed. Read the comment docs.

@@ -125,8 +125,7 @@ are some helper scripts to make this easier (from [here](https://cloud.google.co

```
gcloud components install docker-credential-gcr
docker-credential-gcr configure-docker
docker-credential-gcr gcr-login
gcloud auth configure-docker
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing to note here is that you can also use an IAM service account and login with docker directly if there's no other need for having gcloud installed on the devices. https://cloud.google.com/container-registry/docs/advanced-authentication basically you create a service account and grant it read only permissions to the GCR storage bucket for the project and then they can login with docker cli directly using the service account json key like this docker login -u _json_key -p "$(cat keyfile.json)" https://us.gcr.io (assuming the key is in ./keyfile.json)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @programatt, sorry for going so long. I've spent some time deep in Docker land in the last few weeks and think it will work well, thanks for all the tips.

We do use gcloud and gsutil pretty extensively and rely on a GCP network connection, so we do need them to authenticate at some point. We are using service account keys in a number of places and they work well.

I think I know have it so the images are public so anyone should be able to pull them, which is what I'm going for.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wtgee awesome! Glad to hear it seems to be going well for this project.

* FITS solving uses pipe
* Removing unused packages
@wtgee
Copy link
Member Author

wtgee commented Jun 29, 2019

Closing in favor of #859

@wtgee wtgee closed this Jun 29, 2019
@wtgee wtgee deleted the new-docker branch August 20, 2022 00:55
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

Successfully merging this pull request may close these issues.

Evaluate Docker as Developer and/or User option
2 participants