Skip to content

Commit c21700f

Browse files
author
Takashi Matsuo
authored
[vision] chore: parameterized FROM, add cloudbuild.yaml (#3842)
* [vision] chore: parameterized FROM, add cloudbuild.yaml also update README with how to build and upload the images. * made the ARG to cover the whole tag * add an envvar for avoid docker error * add more envvars to avoid docker error
1 parent 21344e0 commit c21700f

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

vision/automl/edge_container_predict/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM tensorflow/serving:1.14.0
15+
ARG TF_SERVING_IMAGE_TAG
16+
FROM tensorflow/serving:${TF_SERVING_IMAGE_TAG}
1617

1718
ENV GCS_READ_CACHE_MAX_STALENESS 300
1819
ENV GCS_STAT_CACHE_MAX_AGE 300

vision/automl/edge_container_predict/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,10 @@ The outputs are
6969
```bash
7070
sudo docker stop ${CONTAINER_NAME}
7171
```
72+
73+
Note: The docker image is uploaded with the following command.
74+
75+
```bash
76+
gcloud builds --project=cloud-devrel-public-resources \
77+
submit --config cloudbuild.yaml
78+
```

vision/automl/edge_container_predict/automl_vision_edge_container_predict_test.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,35 @@
6060
def edge_container_predict_server_port():
6161
# set up
6262
# Pull the CPU docker.
63-
subprocess.check_output(['docker', 'pull', CPU_DOCKER_GCS_PATH])
63+
subprocess.check_output(
64+
['docker', 'pull', CPU_DOCKER_GCS_PATH],
65+
env={'DOCKER_API_VERSION': '1.38'})
6466

6567
# Get the sample saved model.
6668
if not os.path.exists(MODEL_PATH):
6769
os.mkdir(MODEL_PATH)
6870
subprocess.check_output(
69-
['gsutil', '-m', 'cp', SAMPLE_SAVED_MODEL, MODEL_PATH])
71+
['gsutil', '-m', 'cp', SAMPLE_SAVED_MODEL, MODEL_PATH])
7072

7173
# Start the CPU docker.
7274
subprocess.Popen(['docker', 'run', '--rm', '--name', NAME, '-v',
7375
MODEL_PATH + ':/tmp/mounted_model/0001', '-p',
7476
str(PORT_NUMBER) + ':8501', '-t',
75-
CPU_DOCKER_GCS_PATH])
77+
CPU_DOCKER_GCS_PATH],
78+
env={'DOCKER_API_VERSION': '1.38'})
7679
# Sleep a few seconds to wait for the container running.
7780
time.sleep(10)
7881

7982
yield PORT_NUMBER
8083

8184
# tear down
8285
# Stop the container.
83-
subprocess.check_output(['docker', 'stop', NAME])
86+
subprocess.check_output(
87+
['docker', 'stop', NAME], env={'DOCKER_API_VERSION': '1.38'})
8488
# Remove the docker image.
85-
subprocess.check_output(['docker', 'rmi', CPU_DOCKER_GCS_PATH])
89+
subprocess.check_output(
90+
['docker', 'rmi', CPU_DOCKER_GCS_PATH],
91+
env={'DOCKER_API_VERSION': '1.38'})
8692

8793

8894
def test_edge_container_predict(capsys, edge_container_predict_server_port):
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
timeout: 3600s
16+
17+
steps:
18+
- name: 'gcr.io/cloud-builders/docker'
19+
args: ['build', '-t', 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0',
20+
'--build-arg', 'TF_SERVING_IMAGE_TAG=1.14.0', '.']
21+
- name: 'gcr.io/cloud-builders/docker'
22+
args: ['build', '-t', 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0-gpu',
23+
'--build-arg', 'TF_SERVING_IMAGE_TAG=1.14.0-gpu', '.']
24+
images:
25+
- 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0'
26+
- 'gcr.io/$PROJECT_ID/gcloud-container-1.14.0-gpu'

0 commit comments

Comments
 (0)