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

Create Dockerfile_prod #64

Merged
merged 4 commits into from
Nov 23, 2021
Merged

Create Dockerfile_prod #64

merged 4 commits into from
Nov 23, 2021

Conversation

JamieTaylor-TUOS
Copy link
Collaborator

Added a Dockerfile which:

  • Uses python:3.9 as base image
  • Installs the PVOutput lib with pip
  • Launches a Jupyter notebook server with the example code

Pull Request

Description

This Docker image is useful as a playground and for working interactively with the PVOuput library via Jupyter.

Fixes #63

How Has This Been Tested?

I have built locally as:

>> docker build -t sheffieldsolar/pvoutput:prod-20211118 -f Dockerfile_prod .

And then tested locally:

>> docker run -it --rm -p 1234:1234 -v .pvoutput.yml:/.pvoutput.yml -e PVOUTPUT_CONFIG=/.pvoutput.yml sheffieldsolar/pvoutput:prod-20211118

This successfully launches a Jupyter notebook which can be accessed from the host machine at http://127.0.0.1:1234.

From there, one can edit and run the code in the examples, or create new notebooks.

Note that the config file is being mounted at runtime to /.pvoutput.yml and the env var PVOUTPUT_CONFIG is being set to point to this location. In production, the config file could be added as a secret, in which case the -v flag can be dropped and the PVOUTPUT_CONFIG env var updated to point to the secret.

Note also, that in order to extract data to the host machine or work with persistent notebook files, it would be necessary for the user to also mount a local host directory where notebooks / data can be saved, using either a bind mount or a volume mount. Alternatively, data could be extracted via the internet (e.g. Google Drive).

I have not updated the README to document this Docker image, as I thought it important to have a hosting solution for the image first, so that users are not required to build locally.

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

JamieTaylor-TUOS and others added 2 commits November 18, 2021 14:35
Added a Dockerfile which:
- Uses python:3.9 as base image
- Installs the PVOutput lib with pip
- Launches a Jupyter notebook server with the example code
@JamieTaylor-TUOS
Copy link
Collaborator Author

@JackKelly or @peterdudfield, please could you review this and if happy, add the production image to a Docker repo (Docker Hub maybe?). Then I'll update the README with usage instructions.

I suggest tagging this build as prod or similar (better yet, generate a release and tag it with the prod-<version> or similar). I will submit another PR for a Dockerised development environment in due course.

@JamieTaylor-TUOS JamieTaylor-TUOS added enhancement New feature or request help wanted Extra attention is needed labels Nov 18, 2021
@JamieTaylor-TUOS
Copy link
Collaborator Author

@flowirtz May prove useful for issue #37

Dockerfile_prod Outdated
@@ -0,0 +1,11 @@
FROM python:3.9

Choose a reason for hiding this comment

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

NIT: By any chance: Did u try the -slim variant of the image?

It's only ~45MB instead of ~330MB and I generally prefer those to make things smaller and faster.
Should just work out of the box, but sometimes it doesn't.

Suggested change
FROM python:3.9
FROM python:3.9-slim

@peterdudfield
Copy link
Contributor

Its it worth putting this in a folder called 'infrastructure/docker' as there will be another (the dev one) docker file soon

@peterdudfield
Copy link
Contributor

Its it worth putting this in a folder called 'infrastructure/docker' as there will be another (the dev one) docker file soon

Here's some code, but we probably need to add some 'key' to this repo
https://github.com/openclimatefix/nowcasting_api/blob/main/.github/workflows/release-docker.yml

@peterdudfield
Copy link
Contributor

Its it worth putting this in a folder called 'infrastructure/docker' as there will be another (the dev one) docker file soon

@JamieTaylor-TUOS shall i do this, and push to this branch?

@peterdudfield
Copy link
Contributor

Ive added issue #76 for pushing the docker file to dockerhub

@peterdudfield peterdudfield merged commit 5c45ecd into main Nov 23, 2021
@peterdudfield peterdudfield deleted the Issue-#63 branch January 4, 2022 11:00
@peterdudfield peterdudfield restored the Issue-#63 branch January 4, 2022 11:00
@peterdudfield peterdudfield deleted the Issue-#63 branch January 4, 2022 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include a production Docker image
3 participants