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

Reduce docker image size #1648

Merged
merged 10 commits into from
Oct 23, 2019
Merged

Reduce docker image size #1648

merged 10 commits into from
Oct 23, 2019

Conversation

wagoodman
Copy link

@wagoodman wagoodman commented Oct 21, 2019

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • updates CHANGELOG.md (if appropriate)
  • updates docstrings for any new functions or function arguments, including docs/outline.toml for API reference docs (if appropriate)

Note that your PR will not be reviewed unless all three boxes are checked.

What does this PR change?

  • Reduces the docker image size from ~900MB to ~490MB by leveraging the python:*-slim images (addressing Optimize our Dockerfiles #1638 ).
  • Introduces a prefect docker image for each supported python version (3.5, 3.6, and 3.7) which are built on each tagged master commit.

Why is this PR important?

This cuts down the time it takes to pull down the prefect image for the first time, thus getting users to their first flow faster.

@wagoodman wagoodman requested a review from cicdw October 21, 2019 19:27
@marvin-robot
Copy link
Member

Here I am, brain the size of a planet and they ask me to welcome you to Prefect.

So, welcome to the community @wagoodman! 🎉 🎉

@wagoodman wagoodman force-pushed the 1638-optimize-docker-image branch 2 times, most recently from 3c91713 to 0e2a95e Compare October 21, 2019 21:14
@codecov
Copy link

codecov bot commented Oct 21, 2019

Codecov Report

Merging #1648 into master will increase coverage by <.01%.
The diff coverage is 100%.

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

A few initial comments - this is exciting!

command: |
docker login --username $DOCKER_HUB_USER --password $DOCKER_HUB_PW
docker push prefecthq/prefect
docker push prefecthq/prefect:${CIRCLE_TAG}-${PYTHON_TAG}
Copy link
Member

Choose a reason for hiding this comment

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

I think we might want to finesse the logic here a little, because I suspect this will end up pushing an image with a messy git tag

Copy link
Author

Choose a reason for hiding this comment

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

I'm open to a better way to do it. I added circle-ci git tag filters here to help reduce the risk of an odd tag coming through.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm yea but won't this job still run on master?

Copy link
Author

Choose a reason for hiding this comment

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

good call, I thought these were anded instead of ored. I'll update...

Copy link
Author

Choose a reason for hiding this comment

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

Interestingly enough there isn't a good way to do this, @TylerWanner and I came up with this combo:

Up to a better approach, but this is all I've got until circleci supports and'ed filters.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is the only place I'm still hesitant; here's what I imagine happening:

  • a PR is merged to master
  • build_docker_image is run
  • CIRCLE_TAG is empty, because this isn't a tagged commit
  • either this step or the build step errors out in some unique way based on this

Everything else looks great though! And to be honest, we could always clean things up if that happens but I want to make sure I understand this piece

Copy link
Author

@wagoodman wagoodman Oct 23, 2019

Choose a reason for hiding this comment

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

I don't believe that it is possible to reach this step because of the workflow filter, however, I'm all on-board for an extra measure of safety. Just added the set -u mentioned below which will fail the build image step on empty env vars.

Dockerfile Show resolved Hide resolved
src/prefect/environments/storage/docker.py Outdated Show resolved Hide resolved
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

Python-wise I'm feeling good about this - @TylerWanner would be interested to hear your thoughts on the circle changes

src/prefect/environments/storage/docker.py Show resolved Hide resolved
assert not storage.env_vars
assert storage.python_dependencies == ["wheel"]
assert storage.env_vars == {
"PREFECT__USER_CONFIG_PATH": "/root/.prefect/config.toml"
Copy link
Member

Choose a reason for hiding this comment

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

@joshmeek do you remember why we had to include this originally? I suspect it's no longer necessary but I don't want to take any chances

Choose a reason for hiding this comment

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

I don't think this is used anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

don't remove it as part of this PR, but do remove it as part of another PR after this gets merged pls

TylerWanner
TylerWanner previously approved these changes Oct 22, 2019
.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@wagoodman wagoodman marked this pull request as ready for review October 22, 2019 20:12
Co-Authored-By: Josh Meek <40716964+joshmeek@users.noreply.github.com>
joshmeek
joshmeek previously approved these changes Oct 22, 2019
Copy link

@joshmeek joshmeek 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 to me, will wait on @cicdw as there is still some unresolved comments

.circleci/config.yml Outdated Show resolved Hide resolved
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

🎉 🚀 awesome!!

@cicdw cicdw merged commit 4588c06 into master Oct 23, 2019
@cicdw cicdw deleted the 1638-optimize-docker-image branch October 23, 2019 15:58
This was referenced Oct 25, 2019
zanieb added a commit that referenced this pull request May 12, 2022
Optimize Dask task runner future resolution
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.

None yet

5 participants