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

build(docker): add Dockerfile and container image build tests #362

Merged
merged 6 commits into from
Mar 17, 2024

Conversation

d33bs
Copy link
Member

@d33bs d33bs commented Jan 2, 2024

Description

This change adds a Dockerfile for pycytominer along with associated checks and tests to ensure the image is prepared for use on distribution platforms like Docker Hub.

A first step towards addressing #214 .

What is the nature of your change?

  • Bug fix (fixes an issue).
  • Enhancement (adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • This change requires a documentation update.

Checklist

Please ensure that all boxes are checked before indicating that a pull request is ready for review.

  • I have read the CONTRIBUTING.md guidelines.
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • New and existing unit tests pass locally with my changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have deleted all non-relevant text in this pull request template.

This change adds a Dockerfile for pycytominer along with associated checks and tests to ensure the image is prepared for use on distribution platforms like Docker Hub.
@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.96%. Comparing base (2cd5ad5) to head (bc093ef).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #362   +/-   ##
=======================================
  Coverage   94.96%   94.96%           
=======================================
  Files          56       56           
  Lines        3136     3136           
=======================================
  Hits         2978     2978           
  Misses        158      158           
Flag Coverage Δ
unittests 94.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kenibrewer
Copy link
Member

Will get around to reviewing this in detail tomorrow. My main suggestions will be focused on seeing if we can find a way to avoid including the entire git history of our repo in the image. I think there's a path forward using poetry-dynamic-versioning[plugin] and relying and built versions of our codebase instead of copied versions.

@gwaybio
Copy link
Member

gwaybio commented Jan 26, 2024

@kenibrewer - let us know if you're able to give this a look. Thanks!

(it is beyond my skill set)

Copy link
Member

@kenibrewer kenibrewer left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in the review @d33bs . Have had some major projects going on at work. Here is some feedback focused primarily on reducing bloat within the docker image which I expect to be quite unwieldy in the current approach.

I tiered my recommendations based on the potential impact and complexity of implementation,

Strongly recommended fixes

  • Do not use poetry virtual environments in the docker image and instead install dependencies directly into base python.
  • Do not install docs dependency group within docker image.

Recommended fixes

Discretionary fixes

Here's a pseudo dockerfile for the last item:

FROM python:latest AS build
COPY pycytominer requirements.txt ./
RUN pip install requirements.txt

FROM build as test
COPY tests requirements-dev.txt ./
RUN pip install requirements-dev.txt

Then use this https://docs.docker.com/build/building/multi-stage/#stop-at-a-specific-build-stage to tag one image as pycytominer-test and other other as pycytominer. Run pytest in the test image and then push the build image to dockerhub.

.github/workflows/integration-test.yml Outdated Show resolved Hide resolved
build/docker/Dockerfile Outdated Show resolved Hide resolved
build/docker/Dockerfile Outdated Show resolved Hide resolved
@d33bs d33bs mentioned this pull request Feb 13, 2024
@d33bs
Copy link
Member Author

d33bs commented Mar 8, 2024

I've added some updates here based on your suggestions @kenibrewer, thanks a bunch for your assistance with the adjacent work in #373! I believe current test failures with the Docker image test revolve around those which I plan to address as part of the changed s3 data locations mentioned in #374 . I'm working on resolving the data issues in #374 before running a full test workflow check here.

@d33bs d33bs requested a review from kenibrewer March 14, 2024 22:55
Copy link
Member

@kenibrewer kenibrewer left a comment

Choose a reason for hiding this comment

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

Looks great! A few minor suggestions for adding clarity to the github actions at your discretion.

.github/workflows/integration-test.yml Outdated Show resolved Hide resolved
.github/workflows/integration-test.yml Outdated Show resolved Hide resolved
build/docker/Dockerfile Outdated Show resolved Hide resolved
@kenibrewer
Copy link
Member

kenibrewer commented Mar 16, 2024

Looks like the extract should probably target '--directory.'

Or maybe we just create the pycytominer directory first

@d33bs
Copy link
Member Author

d33bs commented Mar 17, 2024

Thanks again @kenibrewer for your review and continued comments! I feel good about where things now stand and will merge this in now.

@d33bs d33bs merged commit 9dd98ac into cytomining:main Mar 17, 2024
11 checks passed
@d33bs d33bs deleted the add-dockerfile branch March 17, 2024 19:43
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.

4 participants