Skip to content

Commit

Permalink
install prefect in base image (unless already installed)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Goodman committed Nov 5, 2019
1 parent 9d2abe3 commit 940ad15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ These changes are available in the [master branch](https://github.com/PrefectHQ/
- Add an informative version header to all Cloud client requests - [#1690](https://github.com/PrefectHQ/prefect/pull/1690)
- Auto-label Flow environments when using Local storage - [#1696](https://github.com/PrefectHQ/prefect/pull/1696)
- Batch upload logs to Cloud in a background thread for improved performance - [#1691](https://github.com/PrefectHQ/prefect/pull/1691)
- Attempt to install prefect in any docker image (if it is not already installed) - [#1704](https://github.com/PrefectHQ/prefect/pull/1704)

### Task Library

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

0 comments on commit 940ad15

Please sign in to comment.