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

fix: fix pass build env when only requirements.txt file exists #53

Merged
merged 1 commit into from
Aug 30, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ tests/cases/executor_3/config.yml
tests/cases/executor_3/Dockerfile
tests/cases/executor_4/__jina__.Dockerfile
tests/cases/executor_4/Dockerfile
tests/cases/executor_6/__jina__.Dockerfile
tests/cases/executor_6/Dockerfile
tests/cases/executor_7/__jina__.Dockerfile
tests/cases/nested/__jina__.Dockerfile
tests/cases/nested/config.yml
Expand Down
5 changes: 3 additions & 2 deletions normalizer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ def normalize(
# if len(base_images) > 0:
# logger.debug(f'=> use base image: {base_images}')
# dockerfile.baseimage = base_images.pop()
if build_env and isinstance(build_env, dict) and len(build_env.keys()):
dockerfile.insert_build_env(build_env)

dockerfile.add_work_dir()
# dockerfile._parser.add_lines(f'RUN pip install jina=={jina_version}')
Expand All @@ -621,6 +619,9 @@ def normalize(
if requirements_path.exists():
dockerfile.add_pip_install()

if build_env and isinstance(build_env, dict) and len(build_env.keys()):
dockerfile.insert_build_env(build_env)

# if len(test_glob) > 0:
# dockerfile.add_unitest()

Expand Down
14 changes: 14 additions & 0 deletions tests/cases/executor_6/Dockerfile.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Jina executor normalizer plugin.
# It is not intended for manual editing.

FROM jinaai/jina:2-py37-perf

# setup the workspace
COPY . /workspace
WORKDIR /workspace

# install the third-party requirements
RUN --mount=type=secret,id=DOMAIN export DOMAIN="$(cat /run/secrets/DOMAIN)" && pip install --default-timeout=1000 --compile --no-cache-dir \
-r requirements.txt

ENTRYPOINT ["jina", "executor", "--uses", "config.yml"]
Empty file.
14 changes: 10 additions & 4 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,23 @@ def test_get_executor_args(package_path, expected_path):
'DOMAIN': "DOMAIN",
'REPO': 'REPO'
}
),
(
Path(__file__).parent / 'cases' / 'executor_2',
None
),
(
Path(__file__).parent / 'cases' / 'executor_7',
Path(__file__).parent / 'cases' / 'executor_6',
{
'DOMAIN': "DOMAIN",
'REPO': 'REPO'
}
),
(
Path(__file__).parent / 'cases' / 'executor_2',
None
Path(__file__).parent / 'cases' / 'executor_7',
{
'DOMAIN': "DOMAIN",
'REPO': 'REPO'
}
),
],
)
Expand Down