[go: nahoru, domu]

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

Copy code as last step of the container build #28

Merged
merged 1 commit into from
Jun 23, 2020
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
14 changes: 10 additions & 4 deletions tensorflow_cloud/containerize.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ def _create_docker_file(self):
"WORKDIR {}".format(self.destination_dir),
]

# Copies the files from the `destination_dir` in docker daemon location
# to the `destination_dir` in docker container filesystem.
lines.append("COPY {} {}".format(self.destination_dir, self.destination_dir))

if self.requirements_txt is not None:
_, requirements_txt_name = os.path.split(self.requirements_txt)
dst_requirements_txt = os.path.join(requirements_txt_name)
requirements_txt_path = os.path.join(
self.destination_dir, requirements_txt_name
)
lines.append(
"COPY {} {}".format(requirements_txt_path, requirements_txt_path)
)
# install pip requirements from requirements_txt if it exists.
lines.append(
"RUN if [ -e {} ]; "
Expand All @@ -165,6 +167,10 @@ def _create_docker_file(self):
):
lines.append("RUN pip install cloud-tpu-client")

# Copies the files from the `destination_dir` in docker daemon location
# to the `destination_dir` in docker container filesystem.
lines.append("COPY {} {}".format(self.destination_dir, self.destination_dir))

docker_entry_point = self.preprocessed_entry_point or self.entry_point
_, docker_entry_point_file_name = os.path.split(docker_entry_point)

Expand Down
5 changes: 3 additions & 2 deletions tests/tensorflow_cloud/containerize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ def test_create_docker_with_requirements(self):
expected_docker_file_lines = [
"FROM tensorflow/tensorflow:{}-gpu\n".format(VERSION),
"WORKDIR /app/\n",
"COPY /app/ /app/\n",
"COPY /app/requirements.txt /app/requirements.txt\n",
"RUN if [ -e requirements.txt ]; "
"then pip install --no-cache -r requirements.txt; fi\n",
"COPY /app/ /app/\n",
'ENTRYPOINT ["python", "mnist_example_using_fit.py"]',
]
self.assert_docker_file(expected_docker_file_lines, lcb.docker_file_path)
Expand Down Expand Up @@ -177,8 +178,8 @@ def test_create_docker_file_with_tpu_config(self):
expected_docker_file_lines = [
"FROM tensorflow/tensorflow:{}\n".format(VERSION),
"WORKDIR /app/\n",
"COPY /app/ /app/\n",
"RUN pip install cloud-tpu-client\n",
"COPY /app/ /app/\n",
'ENTRYPOINT ["python", "mnist_example_using_fit.py"]',
]
self.assert_docker_file(expected_docker_file_lines, lcb.docker_file_path)
Expand Down