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

Always attempt to install prefect in base image #1704

Merged
merged 3 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ These changes are available in the [master branch](https://github.com/PrefectHQ/
### Fixes

- Fix Fargate Agent access defaults and environment variable support - [#1687](https://github.com/PrefectHQ/prefect/pull/1687)
- Attempt to install prefect in any docker image (if it is not already installed) - [#1704](https://github.com/PrefectHQ/prefect/pull/1704)

### Deprecations

Expand Down
17 changes: 10 additions & 7 deletions src/prefect/environments/storage/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,20 @@ def __init__(
else:
# create an image from python:*-slim directly
self.base_image = "python:{}-slim".format(python_version)
self.extra_commands.extend(
[
"apt update && apt install -y gcc git && rm -rf /var/lib/apt/lists/*",
"pip install git+https://github.com/PrefectHQ/prefect.git@{}#egg=prefect[kubernetes]".format(
self.prefect_version
),
]
self.extra_commands.append(
"apt update && apt install -y gcc git && rm -rf /var/lib/apt/lists/*",
)
else:
self.base_image = base_image

# we should always try to install prefect, unless it is already installed. We can't determine this until
# image build time.
self.extra_commands.append(
"pip show prefect || pip install git+https://github.com/PrefectHQ/prefect.git@{}#egg=prefect[kubernetes]".format(
self.prefect_version
),
)

not_absolute = [
file_path for file_path in self.files if not os.path.isabs(file_path)
]
Expand Down
4 changes: 2 additions & 2 deletions tests/environments/storage/test_docker_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ def test_create_dockerfile_from_base_image():
"master",
(
"FROM python:3.6-slim",
"pip install git+https://github.com/PrefectHQ/prefect.git@master",
"pip show prefect || pip install git+https://github.com/PrefectHQ/prefect.git@master",
),
),
(
"424be6b5ed8d3be85064de4b95b5c3d7cb665510",
(
"FROM python:3.6-slim",
"apt update && apt install -y gcc git && rm -rf /var/lib/apt/lists/*",
"pip install git+https://github.com/PrefectHQ/prefect.git@424be6b5ed8d3be85064de4b95b5c3d7cb665510#egg=prefect[kubernetes]",
"pip show prefect || pip install git+https://github.com/PrefectHQ/prefect.git@424be6b5ed8d3be85064de4b95b5c3d7cb665510#egg=prefect[kubernetes]",
),
),
],
Expand Down